Package org.sonar.plugins.python.indexer
Class PackageRootResolver
java.lang.Object
org.sonar.plugins.python.indexer.PackageRootResolver
Resolves package root directories for Python projects.
This class is the single source of truth for package root resolution. It handles:
- Extraction from pyproject.toml build system configurations
- Extraction from setup.py configurations
- When no build config files exist: returns empty roots so that FQN resolution falls back
to legacy __init__.py-based detection (see
SymbolUtils.pythonPackageName(java.io.File, java.util.List<java.lang.String>, java.lang.String)) - Fallback when build files exist but provide no roots: conventional folders (src/, lib/), then sonar.sources, then base directory
-
Method Summary
Modifier and TypeMethodDescriptionstatic PackageResolutionResultresolve(org.sonar.api.batch.fs.FileSystem fileSystem, org.sonar.api.config.Configuration config) Resolves package root directories for the project.
-
Method Details
-
resolve
public static PackageResolutionResult resolve(org.sonar.api.batch.fs.FileSystem fileSystem, org.sonar.api.config.Configuration config) Resolves package root directories for the project.Attempts to extract source roots from pyproject.toml and setup.py build system configurations. When no build config files exist, returns empty roots so that FQN resolution falls back to legacy __init__.py-based detection. When build config files exist but provide no source roots, conventional folders take priority over sonar.sources, then base directory as last resort.
- Parameters:
fileSystem- the Sonar file system providing the base directoryconfig- the Sonar configuration- Returns:
- resolution result including resolved root absolute paths and method information
-