SourceCodeAnalysis.ElementSuggestion (Java SE 26 & JDK 26)
Description: declaration: module: jdk.jshell, package: jdk.jshell, class: SourceCodeAnalysis, interface: ElementSuggestion
Keywords: jdk.jshell.SourceCodeAnalysis.ElementSuggestion interface

# Interface SourceCodeAnalysis.ElementSuggestion

Enclosing class:
  `SourceCodeAnalysis`

public static sealed interface SourceCodeAnalysis.ElementSuggestion
A description of an Element that is a possible continuation of a given snippet.

API Note:
  Instances of this interface and instances of the returned Elements should only be used and held during the execution of the `SourceCodeAnalysis.completionSuggestions(java.lang.String, int, jdk.jshell.SourceCodeAnalysis.ElementSuggestionConvertor)` method. Their use outside of the context of the method is not supported and the effect is undefined.
Since:
  26

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `anchor()`
  Returns the offset in the original snippet at which point this Element should be inserted..
  `Supplier<String>`
  `documentation()`
  Returns a Supplier for the javadoc documentation for this Element..
  `Element`
  `element()`
  Returns a possible continuation Element, or `null` if this item does not represent an Element..
  `String`
  `keyword()`
  Returns a possible continuation keyword, or `null` if this item does not represent a keyword..
  `boolean`
  `matchesType()`
  Returns `true` if this Element's type fits into the context..

- ## Method Details

  - ### element

    Element element()
    Returns a possible continuation Element, or `null` if this item does not represent an Element..
    Returns:
      a possible continuation Element, or `null` if this item does not represent an Element.

  - ### keyword

    String keyword()
    Returns a possible continuation keyword, or `null` if this item does not represent a keyword..
    Returns:
      a possible continuation keyword, or `null` if this item does not represent a keyword.

  - ### matchesType

    boolean matchesType()
    Returns `true` if this Element's type fits into the context.. Typically used when the type of the element fits the expected type.
    Returns:
      `true` if this Element's type fits into the context.

  - ### anchor

    int anchor()
    Returns the offset in the original snippet at which point this Element should be inserted..
    Returns:
      the offset in the original snippet at which point this Element should be inserted.

  - ### documentation

    Supplier<String> documentation()
    Returns a Supplier for the javadoc documentation for this Element..
    API Note:
      The instance returned from this method is safe to hold for extended periods of time, and can be called outside of the context of the `SourceCodeAnalysis.completionSuggestions(java.lang.String, int, jdk.jshell.SourceCodeAnalysis.ElementSuggestionConvertor)` method.
    Returns:
      a Supplier for the javadoc documentation for this Element.