Provides analysis utilities for source code input. Optional functionality that provides for a richer interactive experience. Includes completion analysis: Is the input a complete snippet of code? Do I need to prompt for more input? Would adding a semicolon make it complete? Is there more than one snippet? etc. Also includes completion suggestions, as might be used in tab-completion.
Nested Classes
static enum
Describes the completeness of the given input.
static interface
The result of analyzeCompletion(String input)
.
static interface
A documentation for a candidate for continuation of the given user's input.
static final class
List of possible qualified names.
static interface
The wrapping of a snippet of Java source into valid top-level Java source.
static interface
A candidate for continuation of the given user's input.
Given an input string, find the first snippet of code (one statement, definition, import, or expression) and evaluate if it is complete.
Infer the type of the given expression.
Compute possible follow-ups for the given input.
Returns a collection of Snippet
s which might need updating if the given Snippet
is updated.
Compute documentation for the given user's input.
List qualified names known for the simple name in the given code immediately to the left of the given cursor position.
Converts the source code of a snippet into a
Snippet
object (or list of
Snippet
objects in the case of some var declarations, e.g.: int x, y, z;).
Returns the wrapper information for the Snippet
.
Returns the wrapper information for the snippet within the input source string.
Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Given an input string, find the first snippet of code (one statement, definition, import, or expression) and evaluate if it is complete.
input
- the input source string
Compute possible follow-ups for the given input. Uses information from the current JShell
state, including type information, to filter the suggestions.
input
- the user input, so far
cursor
- the current position of the cursors in the given input
text
anchor
- outgoing parameter - when an option will be completed, the text between the anchor and cursor will be deleted and replaced with the given option
Compute documentation for the given user's input. Multiple Documentation
objects may be returned when multiple elements match the user's input (like for overloaded methods).
input
- the snippet the user wrote so far
cursor
- the current position of the cursors in the given input
text
computeJavadoc
- true if the javadoc for the given input should be computed in addition to the signature
Documentation
objects are returned.
Infer the type of the given expression. The expression spans from the beginning of 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 inferred
cursor
- current cursor position in the given code
List qualified names known for the simple name in the given code immediately to the left of the given cursor position. The qualified names are gathered by inspecting the classpath used by eval (see
JShell.addToClasspath(java.lang.String)
).
code
- the expression for which the candidate qualified names should be computed
cursor
- current cursor position in the given code
Returns the wrapper information for the 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 wrapper
Returns the wrapper information for the snippet within the input source string.
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 wrappers
Converts the source code of a snippet into a
Snippet
object (or list of
Snippet
objects in the case of some var declarations, e.g.: int x, y, z;). Does not install the snippets: declarations are not accessible by other snippets; imports are not added. Does not execute the snippets.
Queries may be done on the Snippet
object. The Snippet.id()
will be "*UNASSOCIATED*"
. The returned snippets are not associated with the JShell
instance, so attempts to pass them to JShell
methods will throw an IllegalArgumentException
. They will not appear in queries for snippets -- for example, JShell.snippets()
.
Restrictions on the input are as in JShell.eval
.
Only preliminary compilation is performed, sufficient to build the Snippet
. Snippets known to be erroneous, are returned as ErroneousSnippet
, other snippets may or may not be in error.
input
- The input String to convert
IllegalStateException
- if the JShell
instance is closed.
Returns a collection of 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4