mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 09:22:19 +00:00
[red-knot] Add filename and source location for diagnostics (#12842)
## Summary I'm not sure if this is useful but this is a hacky implementation to add the filename and row / column numbers to the current Red Knot diagnostics.
This commit is contained in:
parent
540023262e
commit
99dc208b00
6 changed files with 74 additions and 12 deletions
|
@ -1,6 +1,8 @@
|
|||
use ruff_db::files::File;
|
||||
use ruff_db::files::{File, FilePath};
|
||||
use ruff_db::source::line_index;
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::{Expr, ExpressionRef, StmtClassDef};
|
||||
use ruff_source_file::LineIndex;
|
||||
|
||||
use crate::module_name::ModuleName;
|
||||
use crate::module_resolver::{resolve_module, Module};
|
||||
|
@ -25,6 +27,14 @@ impl<'db> SemanticModel<'db> {
|
|||
self.db
|
||||
}
|
||||
|
||||
pub fn file_path(&self) -> &FilePath {
|
||||
self.file.path(self.db)
|
||||
}
|
||||
|
||||
pub fn line_index(&self) -> LineIndex {
|
||||
line_index(self.db.upcast(), self.file)
|
||||
}
|
||||
|
||||
pub fn resolve_module(&self, module_name: ModuleName) -> Option<Module> {
|
||||
resolve_module(self.db, module_name)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue