public abstract class AbstractRoutineRefResolver extends Object
Owns the common resolve() loop: builds uppercase and name-based indexes, iterates all unresolved refs, delegates per-ref resolution to subclass, and replaces the ref list on the program.
Dialect-specific resolution tiers (qualified match, schema inference,
default schema, etc.) belong in the subclass tryResolve(gudusoft.gsqlparser.ir.bound.BoundRoutineRef, gudusoft.gsqlparser.ir.bound.BoundProgram, java.util.Map<java.lang.String, gudusoft.gsqlparser.ir.bound.BoundRoutineSymbol>, java.util.Map<java.lang.String, java.util.List<gudusoft.gsqlparser.ir.bound.BoundRoutineSymbol>>) method.
| Constructor and Description |
|---|
AbstractRoutineRefResolver() |
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,List<BoundRoutineSymbol>> |
buildNameIndex(BoundProgram program)
Builds a case-insensitive name → list of symbols index.
|
protected Map<String,BoundRoutineSymbol> |
buildUpperCaseIndex(BoundProgram program)
Builds a case-insensitive routineId → symbol index.
|
protected abstract void |
classifyExternalIfKnown(BoundRoutineRef ref)
Called for unresolved refs to check if they are known external dependencies.
|
protected static BoundRoutineSymbol |
findBestDefaultParamMatch(Map<String,List<BoundRoutineSymbol>> nameIndex,
String upperName,
int argCount)
Finds the best default-parameter match (smallest paramCount > argCount).
|
protected static List<BoundRoutineSymbol> |
findByNameAndArgCount(Map<String,List<BoundRoutineSymbol>> nameIndex,
String upperName,
int argCount)
Finds candidates matching a name and exact arg count from the name index.
|
void |
resolve(BoundProgram program)
Resolves all unresolved routine refs in the program.
|
protected static BoundRoutineSymbol |
tryKindVariants(Map<String,BoundRoutineSymbol> ciIndex,
String baseName,
int argCount,
String[] kindCodes)
Tries all KIND code variants for a given base name and argCount.
|
protected abstract BoundRoutineRef |
tryResolve(BoundRoutineRef ref,
BoundProgram program,
Map<String,BoundRoutineSymbol> upperIndex,
Map<String,List<BoundRoutineSymbol>> nameIndex)
Attempts to resolve a single routine ref against the known routines.
|
public AbstractRoutineRefResolver()
public final void resolve(BoundProgram program)
protected abstract BoundRoutineRef tryResolve(BoundRoutineRef ref, BoundProgram program, Map<String,BoundRoutineSymbol> upperIndex, Map<String,List<BoundRoutineSymbol>> nameIndex)
ref - the unresolved refprogram - the program containing all routinesupperIndex - case-insensitive routineId → symbol indexnameIndex - case-insensitive name → list of symbols indexprotected abstract void classifyExternalIfKnown(BoundRoutineRef ref)
protected final Map<String,BoundRoutineSymbol> buildUpperCaseIndex(BoundProgram program)
protected final Map<String,List<BoundRoutineSymbol>> buildNameIndex(BoundProgram program)
protected static BoundRoutineSymbol tryKindVariants(Map<String,BoundRoutineSymbol> ciIndex, String baseName, int argCount, String[] kindCodes)
protected static List<BoundRoutineSymbol> findByNameAndArgCount(Map<String,List<BoundRoutineSymbol>> nameIndex, String upperName, int argCount)
protected static BoundRoutineSymbol findBestDefaultParamMatch(Map<String,List<BoundRoutineSymbol>> nameIndex, String upperName, int argCount)