Class ConfigurationField

java.lang.Object
org.eclipse.lemminx.commons.config.ConfigurationField

public class ConfigurationField extends Object
Represents a configuration field discovered by scanning a settings class hierarchy. Each instance pairs a reflective Field path (parent chain + leaf) with a configuration section name (e.g. "xml.format.maxLineWidth" or "xml.validation.namespaces.enabled"). Used by the scoped workspace/configuration pull mechanism.

The scan is driven by Scope annotations: only leaf fields annotated with @Scope(ConfigurationScope.RESOURCE) are included. Object fields without @Scope are recursed into automatically, supporting arbitrary nesting depth.

  • Method Details

    • getSection

      public String getSection()
      Returns the configuration section name (e.g. "xml.format.splitAttributes").
    • computeConfigurationFields

      public static List<ConfigurationField> computeConfigurationFields(Class<?> clazz, String prefix)
      Recursively scan the given class hierarchy for fields annotated with Scope. Object fields without @Scope are recursed into; leaf fields (primitives, String, List, enums) with @Scope are collected.
      Parameters:
      clazz - the root class to scan (e.g. XMLGeneralClientSettings.class).
      prefix - the configuration section prefix (e.g. "xml.").
      Returns:
      an unmodifiable list of ConfigurationField instances.
    • createConfigurationParams

      public static org.eclipse.lsp4j.ConfigurationParams createConfigurationParams(String scopeUri, List<ConfigurationField> fields)
      Create a ConfigurationParams for pulling scoped configuration values from the client. Each ConfigurationField produces one ConfigurationItem with the given scopeUri.
      Parameters:
      scopeUri - the document URI to scope the configuration to.
      fields - the configuration fields to request.
      Returns:
      the configuration params ready to send via workspace/configuration.
    • applyConfigurationResults

      public static void applyConfigurationResults(Object root, List<ConfigurationField> fields, List<Object> results)
      Apply the results of a workspace/configuration response to the given root object. For each result, the method navigates the parent path on the root object, then sets the leaf field value. Null results are skipped (the field retains its current value).
      Parameters:
      root - the root object (e.g. a SharedSettings instance).
      fields - the configuration fields, in the same order as the configuration request items.
      results - the configuration response values, one per field.
    • haveSameValues

      public static boolean haveSameValues(Object a, Object b, List<ConfigurationField> fields)
      Compare the scoped field values between two root objects. Returns true if all Scope-annotated fields have the same values in both objects.
      Parameters:
      a - the first root object.
      b - the second root object.
      fields - the configuration fields to compare.
      Returns:
      true if all scoped values are equal.