Ragex.Editor.Conflict (Ragex v0.8.0)

View Source

Conflict detection for refactoring operations.

Detects potential conflicts before applying refactoring changes:

  • Name conflicts (duplicate names)
  • Scope conflicts (visibility issues)
  • Dependency conflicts (broken references)
  • Concurrent modifications (file changed since analysis)
  • Visibility conflicts (private function made public with broken callers)

Summary

Functions

Checks for concurrent file modifications.

Checks for conflicts when extracting a module.

Checks for conflicts when moving a function between modules.

Checks for naming conflicts when renaming a function.

Checks for visibility conflicts when changing function visibility.

Types

conflict()

@type conflict() :: %{
  type: conflict_type(),
  severity: :error | :warning | :info,
  message: String.t(),
  file: String.t() | nil,
  line: pos_integer() | nil,
  suggestion: String.t() | nil
}

conflict_result()

@type conflict_result() :: %{
  has_conflicts: boolean(),
  conflicts: [conflict()],
  stats: %{
    errors: non_neg_integer(),
    warnings: non_neg_integer(),
    infos: non_neg_integer()
  }
}

conflict_type()

@type conflict_type() ::
  :name_conflict
  | :scope_conflict
  | :dependency_conflict
  | :concurrent_modification
  | :visibility_conflict

Functions

check_concurrent_modification(file_path, expected_mtime)

@spec check_concurrent_modification(String.t(), integer() | nil) ::
  {:ok, conflict_result()}

Checks for concurrent file modifications.

Parameters

  • file_path: Path to file
  • expected_mtime: Expected modification time (from when analysis was done)

Returns

  • {:ok, conflict_result} with any detected conflicts

check_extract_module_conflicts(source_module, new_module, functions)

@spec check_extract_module_conflicts(atom(), atom(), [{atom(), non_neg_integer()}]) ::
  {:ok, conflict_result()}

Checks for conflicts when extracting a module.

Parameters

  • source_module: Module to extract from
  • new_module: Name for new module
  • functions: List of {name, arity} tuples to extract

Returns

  • {:ok, conflict_result} with any detected conflicts

check_move_conflicts(source_module, target_module, function_name, arity)

@spec check_move_conflicts(atom(), atom(), atom(), non_neg_integer()) ::
  {:ok, conflict_result()}

Checks for conflicts when moving a function between modules.

Parameters

  • source_module: Source module
  • target_module: Target module
  • function_name: Function to move
  • arity: Function arity

Returns

  • {:ok, conflict_result} with any detected conflicts

check_rename_conflicts(module_name, new_name, arity)

@spec check_rename_conflicts(atom(), atom(), non_neg_integer()) ::
  {:ok, conflict_result()}

Checks for naming conflicts when renaming a function.

Parameters

  • module_name: Module containing the function
  • new_name: Proposed new name
  • arity: Function arity

Returns

  • {:ok, conflict_result} with any detected conflicts

check_visibility_conflicts(module_name, function_name, arity, new_visibility)

@spec check_visibility_conflicts(
  atom(),
  atom(),
  non_neg_integer(),
  :public | :private
) ::
  {:ok, conflict_result()}

Checks for visibility conflicts when changing function visibility.

Parameters

  • module_name: Module containing function
  • function_name: Function name
  • arity: Function arity
  • new_visibility: :public or :private

Returns

  • {:ok, conflict_result} with any detected conflicts