- Enclosing class:
- SourceCodeAnalysis
public static interface SourceCodeAnalysis.SnippetWrapper
The wrapping of a snippet of Java source into valid top-level Java
source. The wrapping will always either be an import or include a
synthetic class at the top-level. If a synthetic class is generated, it
will be proceeded by the package and import declarations, and may contain
synthetic class members.
This interface, in addition to the mapped form, provides the context and position mapping information.
-
Method Summary
Modifier and Type Method Description String
fullClassName()
Returns the fully qualified class name of thewrapped()
class.Snippet.Kind
kind()
Returns theSnippet.Kind
of thesource()
.String
source()
Returns the input that is wrapped.int
sourceToWrappedPosition(int pos)
Maps character position within the source to character position within the wrapped.String
wrapped()
Returns a Java class definition that wraps thesource()
or, if an import, the import source.int
wrappedToSourcePosition(int pos)
Maps character position within the wrapped to character position within the source.
-
Method Details
-
source
String source()Returns the input that is wrapped. Forwrappers(String)
, this is the source of the snippet within the input. A variable declaration ofN
variables will map toN
wrappers with the source separated.For
wrapper(Snippet)
, this isSnippet.source()
.- Returns:
- the input source corresponding to the wrapper.
-
wrapped
String wrapped()Returns a Java class definition that wraps thesource()
or, if an import, the import source.If the input is not a valid Snippet, this will not be a valid class/import definition.
The source may be divided and mapped to different locations within the wrapped source.
- Returns:
- the source wrapped into top-level Java code
-
fullClassName
String fullClassName()Returns the fully qualified class name of thewrapped()
class. For erroneous input, a best guess is returned.- Returns:
- the name of the synthetic wrapped class; if an import, the name is not defined
-
kind
Snippet.Kind kind()Returns theSnippet.Kind
of thesource()
.- Returns:
- an enum representing the general kind of snippet.
-
sourceToWrappedPosition
int sourceToWrappedPosition(int pos)Maps character position within the source to character position within the wrapped. -
wrappedToSourcePosition
int wrappedToSourcePosition(int pos)Maps character position within the wrapped to character position within the source.
-