public final class ElementHeaders extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ANNOTATIONS |
static String |
EXTENDS |
static String |
FLAGS |
static String |
IMPLEMENTS |
static String |
NAME |
static String |
PARAMETERS |
static String |
THROWS |
static String |
TYPE |
static String |
TYPEPARAMETERS |
Modifier and Type | Method and Description |
---|---|
static StructureElement |
convertElement(CompilationInfo info,
Element el,
ElementUtilities.ElementAcceptor childAcceptor,
boolean allowBinary)
Describes a javac
Element as LSP StructureElement . |
static int |
getDistance(String s,
String t)
Computes distance between strings
|
static String |
getHeader(Element element,
CompilationInfo info,
String formatString)
Formats header of an element.
|
static String |
getHeader(TreePath treePath,
CompilationInfo info,
String formatString)
Formats header of a tree.
|
static StructureElement.Kind |
javaKind2Structure(Element el)
Converts Javac
ElementKind to a suitable LSP structure kind. |
static CompletableFuture<StructureElement> |
resolveStructureElement(CompilationInfo info,
Element el,
boolean resolveSources)
Converts a javac
Element into LSP StructureElement . |
static StructureElement |
toStructureElement(CompilationInfo info,
Element el,
ElementUtilities.ElementAcceptor childAcceptor)
Converts an javac
Element into LSP StructureElement . |
public static final String ANNOTATIONS
public static final String NAME
public static final String TYPE
public static final String THROWS
public static final String IMPLEMENTS
public static final String EXTENDS
public static final String TYPEPARAMETERS
public static final String FLAGS
public static final String PARAMETERS
public static String getHeader(TreePath treePath, CompilationInfo info, String formatString)
"method " + NAME + PARAMETERS + " has return type " + TYPE
treePath
- TreePath to the tree header is required forinfo
- CompilationInfoformatString
- Formating stringpublic static String getHeader(Element element, CompilationInfo info, String formatString)
"method " + NAME + PARAMETERS + " has return type " + TYPE
element
- Element to be formatedinfo
- Compilation infoformatString
- Formating stringpublic static int getDistance(String s, String t)
s
- First stringt
- Second strings
to t
.@CheckForNull public static StructureElement toStructureElement(CompilationInfo info, Element el, ElementUtilities.ElementAcceptor childAcceptor)
Element
into LSP StructureElement
. This method does not
work for binary elements, just for elements from the parsed source. To work with
non-local elements, use ElementHeaders.resolveStructureElement(org.netbeans.api.java.source.CompilationInfo, javax.lang.model.element.Element, boolean)
. If childAcceptor
is not null
, children are fetched recursively and filed into StructureElement.getChildren()
;
the acceptor is applied to all levels. The method returns null
if the passed CompilationInfo
does not contain source information for the Element.info
- compilation infoel
- element to convertchildAcceptor
- null
to ignore children, non-null to filter.null
public static CompletableFuture<StructureElement> resolveStructureElement(CompilationInfo info, Element el, boolean resolveSources)
Element
into LSP StructureElement
. This method supports also elements that are not part of
the "info
" compilation. If `resolveSources
' is true, it will try to acquire their relevant source, possibly using
SourceJavadocAttacher
API.
As this process may take some time, the call may complete asynchronously when the element's source is acquired. null
is returned for Elements outside that have no source associated when resolveSources
is false.
Calling CompletableFuture.cancel(boolean)
on the returned value performs cancel on the possible long-running task(s) in a best-effort way: it is
not guaranteed that the already started processes interrupts.
info
- compilationel
- the element to convertresolveSources
- public static StructureElement convertElement(CompilationInfo info, Element el, ElementUtilities.ElementAcceptor childAcceptor, boolean allowBinary)
Element
as LSP StructureElement
. Source file and position information may not be provided, but
the other fields of the StructureElement
will be filled. If `allowBinaries' is true, the file member of the StructureElement
may
be filled with FileObject of binary that defines the Element
; source FileObject is always preferred, if available.info
- compilationel
- the element to convertpublic static StructureElement.Kind javaKind2Structure(Element el)
ElementKind
to a suitable LSP structure kind. Note
that not all kinds are supported - such ElementKinds are converted tokind
-