Skip to content

KaDanglingFileResolutionModeProvider

A service that provides KaDanglingFileResolutionMode for a given KtFile based purely on its content.

The service is aimed at taking unnecessary workload off developers when choosing KaDanglingFileResolutionMode for analyzeCopy calls. Rare use-cases with file copies might require some particular resolution mode, however, usually KaDanglingFileResolutionMode is just an optimization to avoid unnecessary FIR resolution in file copies. But when working with some generic file copies, it's almost impossible to correctly determine whether an out-of-block modification is present in the file copy without a sophisticated file analysis. Implementing this additional logic for a low-level optimization definitely shouldn't be done by the users of Analysis API. KaDanglingFileResolutionModeProvider should be the main source of truth for determining the resolution mode for file copies.

Types

Companion

object Companion

Functions

calculateMode

Calculates KaDanglingFileResolutionMode for the given file.

This mode is calculated based solely on the difference between the given dangling file and its copyOrigin. If there was an out-of-block modification made in the file compared to its copyOrigin, returns KaDanglingFileResolutionMode.PREFER_SELF. Otherwise, returns KaDanglingFileResolutionMode.IGNORE_SELF.

If the given file is not a dangling one, returns KaDanglingFileResolutionMode.PREFER_SELF.