Class SourceCodeParameterNameResolver


  • public class SourceCodeParameterNameResolver
    extends java.lang.Object
    Centralized resolver for extracting parameter names from source code. Uses JavaParser to parse method signatures and extract actual parameter names.

    Features: - Thread-safe caching for performance - Fallback to reflection-based names when source parsing fails - Integration with existing FileFinder and FileParser infrastructure - Robust error handling and logging

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearCache()
      Clears the parameter name cache.
      int getCacheSize()
      Gets cache statistics for monitoring and debugging.
      static SourceCodeParameterNameResolver getInstance()  
      java.lang.String getParameterName​(java.lang.reflect.Method method, int parameterIndex)
      Gets a single parameter name by index, with appropriate fallback.
      java.util.List<java.lang.String> resolveParameterNames​(java.lang.reflect.Method method)
      Resolves parameter names for a given method, using source code parsing when possible.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • resolveParameterNames

        public java.util.List<java.lang.String> resolveParameterNames​(java.lang.reflect.Method method)
        Resolves parameter names for a given method, using source code parsing when possible. Falls back to reflection-based names if source parsing fails.
        Parameters:
        method - the method to resolve parameter names for
        Returns:
        list of parameter names, or empty list if method is null
      • getParameterName

        public java.lang.String getParameterName​(java.lang.reflect.Method method,
                                                 int parameterIndex)
        Gets a single parameter name by index, with appropriate fallback.
        Parameters:
        method - the method to get parameter name for
        parameterIndex - the index of the parameter (0-based)
        Returns:
        the parameter name, or "param{index}" as ultimate fallback
      • clearCache

        public void clearCache()
        Clears the parameter name cache. Useful for testing or memory management.
      • getCacheSize

        public int getCacheSize()
        Gets cache statistics for monitoring and debugging.
        Returns:
        the current number of cached parameter name entries