Class FuzzySymbolSearch

java.lang.Object
org.ek9lang.compiler.search.FuzzySymbolSearch

public final class FuzzySymbolSearch extends Object
Provides fuzzy symbol search functionality using Levenshtein distance. Used to generate "Did you mean?" suggestions when symbols cannot be resolved.

This class searches scopes and aggregates for symbols with names similar to a target name, returning the best matches ordered by similarity (lowest cost first).

Callers should check whether fuzzy suggestions are enabled (E2+ error level) before invoking these methods, via ErrorListener.isFuzzySuggestionsEnabled().

  • Constructor Details

    • FuzzySymbolSearch

      public FuzzySymbolSearch()
  • Method Details

    • findSimilarSymbols

      public MatchResults findSimilarSymbols(IScope scope, String targetName)
      Search for symbols with names similar to the target name in the given scope and all enclosing scopes.
      Parameters:
      scope - The scope to start searching from
      targetName - The name to find similar matches for
      Returns:
      MatchResults containing the best matches (up to MAX_RESULTS)
    • findSimilarMethods

      public MatchResults findSimilarMethods(IAggregateSymbol aggregate, String methodName)
      Search for methods with names similar to the target method name in the given aggregate and its super aggregates.
      Parameters:
      aggregate - The aggregate to search in
      methodName - The method name to find similar matches for
      Returns:
      MatchResults containing the best matching methods (up to MAX_RESULTS)
    • findSimilarProperties

      public MatchResults findSimilarProperties(IAggregateSymbol aggregate, String propertyName)
      Search for properties with names similar to the target property name in the given aggregate.
      Parameters:
      aggregate - The aggregate to search in
      propertyName - The property name to find similar matches for
      Returns:
      MatchResults containing the best matching properties (up to MAX_RESULTS)
    • findSimilarTypes

      public MatchResults findSimilarTypes(IScope scope, String typeName)
      Search for types with names similar to the target type name in the given scope and all enclosing scopes.
      Parameters:
      scope - The scope to start searching from
      typeName - The type name to find similar matches for
      Returns:
      MatchResults containing the best matching types (up to MAX_RESULTS)