mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-28 15:33:50 +00:00
Make Definition
a salsa-ingredient (#12151)
This commit is contained in:
parent
e6e09ea93a
commit
3ce8b9fcae
11 changed files with 499 additions and 707 deletions
|
@ -4,9 +4,8 @@ use ruff_python_ast as ast;
|
|||
use ruff_python_ast::{Expr, ExpressionRef, StmtClassDef};
|
||||
|
||||
use crate::semantic_index::ast_ids::HasScopedAstId;
|
||||
use crate::semantic_index::definition::Definition;
|
||||
use crate::semantic_index::symbol::PublicSymbolId;
|
||||
use crate::semantic_index::{public_symbol, semantic_index, NodeWithScopeKey};
|
||||
use crate::semantic_index::{public_symbol, semantic_index};
|
||||
use crate::types::{infer_types, public_symbol_ty, Type, TypingContext};
|
||||
use crate::Db;
|
||||
|
||||
|
@ -143,12 +142,10 @@ impl HasTy for ast::Expr {
|
|||
impl HasTy for ast::StmtFunctionDef {
|
||||
fn ty<'db>(&self, model: &SemanticModel<'db>) -> Type<'db> {
|
||||
let index = semantic_index(model.db, model.file);
|
||||
let definition_scope = index.definition_scope(NodeWithScopeKey::from(self));
|
||||
|
||||
let scope = definition_scope.to_scope_id(model.db, model.file);
|
||||
let definition = index.definition(self);
|
||||
|
||||
let scope = definition.scope(model.db).to_scope_id(model.db, model.file);
|
||||
let types = infer_types(model.db, scope);
|
||||
let definition = Definition::FunctionDef(self.scoped_ast_id(model.db, scope));
|
||||
|
||||
types.definition_ty(definition)
|
||||
}
|
||||
|
@ -157,11 +154,10 @@ impl HasTy for ast::StmtFunctionDef {
|
|||
impl HasTy for StmtClassDef {
|
||||
fn ty<'db>(&self, model: &SemanticModel<'db>) -> Type<'db> {
|
||||
let index = semantic_index(model.db, model.file);
|
||||
let definition_scope = index.definition_scope(NodeWithScopeKey::from(self));
|
||||
let scope = definition_scope.to_scope_id(model.db, model.file);
|
||||
let definition = index.definition(self);
|
||||
|
||||
let scope = definition.scope(model.db).to_scope_id(model.db, model.file);
|
||||
let types = infer_types(model.db, scope);
|
||||
let definition = Definition::ClassDef(self.scoped_ast_id(model.db, scope));
|
||||
|
||||
types.definition_ty(definition)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue