mirror of https://github.com/astral-sh/ruff
[ty_test] Move HoverOutput to hover module
Move the HoverOutput type from check_output.rs to hover.rs where it logically belongs. The check_output module should only contain the CheckOutput enum and sorting infrastructure, while hover-specific types belong in the hover module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
35a5fd767d
commit
35b568dd6b
|
|
@ -5,17 +5,9 @@
|
|||
|
||||
use ruff_db::diagnostic::Diagnostic;
|
||||
use ruff_source_file::{LineIndex, OneIndexed};
|
||||
use ruff_text_size::TextSize;
|
||||
use std::ops::Range;
|
||||
|
||||
/// A hover result for testing hover assertions.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct HoverOutput {
|
||||
/// The position where hover was requested
|
||||
pub(crate) offset: TextSize,
|
||||
/// The inferred type at that position
|
||||
pub(crate) inferred_type: String,
|
||||
}
|
||||
use crate::hover::HoverOutput;
|
||||
|
||||
/// Represents either a diagnostic or a hover result for matching against assertions.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
//! This module provides functionality to extract hover assertions from comments,
|
||||
//! infer types at specified positions, and generate hover check outputs for matching.
|
||||
|
||||
use crate::check_output::{CheckOutput, HoverOutput};
|
||||
use ruff_db::files::File;
|
||||
use ruff_db::parsed::parsed_module;
|
||||
use ruff_db::source::{line_index, source_text};
|
||||
|
|
@ -12,8 +11,18 @@ use ruff_python_ast::AnyNodeRef;
|
|||
use ruff_text_size::{Ranged, TextSize};
|
||||
use ty_python_semantic::{HasType, SemanticModel};
|
||||
|
||||
use crate::check_output::CheckOutput;
|
||||
use crate::db::Db;
|
||||
|
||||
/// A hover result for testing hover assertions.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct HoverOutput {
|
||||
/// The position where hover was requested
|
||||
pub(crate) offset: TextSize,
|
||||
/// The inferred type at that position
|
||||
pub(crate) inferred_type: String,
|
||||
}
|
||||
|
||||
/// Find the AST node with minimal range that fully contains the given offset.
|
||||
fn find_covering_node<'a>(root: AnyNodeRef<'a>, offset: TextSize) -> Option<AnyNodeRef<'a>> {
|
||||
struct Visitor<'a> {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ use ruff_db::source::{SourceText, line_index, source_text};
|
|||
use ruff_source_file::{LineIndex, OneIndexed};
|
||||
|
||||
use crate::assertion::{InlineFileAssertions, ParsedAssertion, UnparsedAssertion};
|
||||
use crate::check_output::{CheckOutput, HoverOutput, LineCheckOutputs, SortedCheckOutputs};
|
||||
use crate::check_output::{CheckOutput, LineCheckOutputs, SortedCheckOutputs};
|
||||
use crate::hover::HoverOutput;
|
||||
use crate::db::Db;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue