mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
[red-knot] Cache source type during semanic index building (#17756)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
67ef370733
commit
9c57862262
1 changed files with 4 additions and 2 deletions
|
@ -10,7 +10,7 @@ use ruff_db::source::{source_text, SourceText};
|
|||
use ruff_index::IndexVec;
|
||||
use ruff_python_ast::name::Name;
|
||||
use ruff_python_ast::visitor::{walk_expr, walk_pattern, walk_stmt, Visitor};
|
||||
use ruff_python_ast::{self as ast, PythonVersion};
|
||||
use ruff_python_ast::{self as ast, PySourceType, PythonVersion};
|
||||
use ruff_python_parser::semantic_errors::{
|
||||
SemanticSyntaxChecker, SemanticSyntaxContext, SemanticSyntaxError,
|
||||
};
|
||||
|
@ -75,6 +75,7 @@ pub(super) struct SemanticIndexBuilder<'db> {
|
|||
// Builder state
|
||||
db: &'db dyn Db,
|
||||
file: File,
|
||||
source_type: PySourceType,
|
||||
module: &'db ParsedModule,
|
||||
scope_stack: Vec<ScopeInfo>,
|
||||
/// The assignments we're currently visiting, with
|
||||
|
@ -118,6 +119,7 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
let mut builder = Self {
|
||||
db,
|
||||
file,
|
||||
source_type: file.source_type(db.upcast()),
|
||||
module: parsed,
|
||||
scope_stack: Vec::new(),
|
||||
current_assignments: vec![],
|
||||
|
@ -445,7 +447,7 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
#[allow(unsafe_code)]
|
||||
// SAFETY: `definition_node` is guaranteed to be a child of `self.module`
|
||||
let kind = unsafe { definition_node.into_owned(self.module.clone()) };
|
||||
let category = kind.category(self.file.is_stub(self.db.upcast()));
|
||||
let category = kind.category(self.source_type.is_stub());
|
||||
let is_reexported = kind.is_reexported();
|
||||
|
||||
let definition = Definition::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue