mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
everysalsa
This commit is contained in:
parent
e69ff21207
commit
fcdf3a52b4
4 changed files with 40 additions and 23 deletions
|
@ -3,13 +3,11 @@ use libsyntax2::File;
|
|||
use libeditor::LineIndex;
|
||||
use {
|
||||
FileId,
|
||||
db::{Query, QueryCtx, QueryRegistry, file_text},
|
||||
db::{Query, QueryCtx, QueryRegistry},
|
||||
symbol_index::SymbolIndex,
|
||||
};
|
||||
|
||||
pub(crate) fn register_queries(reg: &mut QueryRegistry) {
|
||||
reg.add(FILE_SYNTAX, "FILE_SYNTAX");
|
||||
reg.add(FILE_LINES, "FILE_LINES");
|
||||
}
|
||||
pub(crate) use db::{file_text, file_set};
|
||||
|
||||
pub(crate) fn file_syntax(ctx: QueryCtx, file_id: FileId) -> File {
|
||||
(&*ctx.get(FILE_SYNTAX, file_id)).clone()
|
||||
|
@ -17,6 +15,9 @@ pub(crate) fn file_syntax(ctx: QueryCtx, file_id: FileId) -> File {
|
|||
pub(crate) fn file_lines(ctx: QueryCtx, file_id: FileId) -> Arc<LineIndex> {
|
||||
ctx.get(FILE_LINES, file_id)
|
||||
}
|
||||
pub(crate) fn file_symbols(ctx: QueryCtx, file_id: FileId) -> Arc<SymbolIndex> {
|
||||
ctx.get(FILE_SYMBOLS, file_id)
|
||||
}
|
||||
|
||||
const FILE_SYNTAX: Query<FileId, File> = Query(16, |ctx, file_id: &FileId| {
|
||||
let text = file_text(ctx, *file_id);
|
||||
|
@ -26,3 +27,13 @@ const FILE_LINES: Query<FileId, LineIndex> = Query(17, |ctx, file_id: &FileId| {
|
|||
let text = file_text(ctx, *file_id);
|
||||
LineIndex::new(&*text)
|
||||
});
|
||||
const FILE_SYMBOLS: Query<FileId, SymbolIndex> = Query(18, |ctx, file_id: &FileId| {
|
||||
let syntax = file_syntax(ctx, *file_id);
|
||||
SymbolIndex::for_file(*file_id, syntax)
|
||||
});
|
||||
|
||||
pub(crate) fn register_queries(reg: &mut QueryRegistry) {
|
||||
reg.add(FILE_SYNTAX, "FILE_SYNTAX");
|
||||
reg.add(FILE_LINES, "FILE_LINES");
|
||||
reg.add(FILE_SYMBOLS, "FILE_SYMBOLS");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue