mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
migrate analysis and server to 2018
This commit is contained in:
parent
2dd6858d03
commit
bb298158eb
21 changed files with 42 additions and 36 deletions
|
@ -1,4 +1,5 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "ra_analysis"
|
||||
version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use salsa;
|
||||
use {FileId, imp::FileResolverImp};
|
||||
use crate::{FileId, imp::FileResolverImp};
|
||||
use super::{State, Query, QueryCtx};
|
||||
|
||||
pub(super) type Data = Arc<Any + Send + Sync + 'static>;
|
||||
|
@ -51,7 +51,7 @@ pub(crate) trait EvalQuery {
|
|||
type Output;
|
||||
fn query_type(&self) -> salsa::QueryTypeId;
|
||||
fn f(&self) -> salsa::QueryFn<State, Data>;
|
||||
fn get(&self, &QueryCtx, Self::Params) -> Arc<Self::Output>;
|
||||
fn get(&self, ctx: &QueryCtx, params: Self::Params) -> Arc<Self::Output>;
|
||||
}
|
||||
|
||||
impl<T, R> EvalQuery for Query<T, R>
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
};
|
||||
use im;
|
||||
use salsa;
|
||||
use {FileId, imp::FileResolverImp};
|
||||
use crate::{FileId, imp::FileResolverImp};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub(crate) struct State {
|
||||
|
@ -75,8 +75,8 @@ pub(crate) fn file_set(ctx: QueryCtx) -> Arc<(Vec<FileId>, FileResolverImp)> {
|
|||
impl QueryRegistry {
|
||||
fn new() -> QueryRegistry {
|
||||
let mut reg = QueryRegistry { imp: imp::QueryRegistry::new() };
|
||||
::queries::register_queries(&mut reg);
|
||||
::module_map::register_queries(&mut reg);
|
||||
crate::queries::register_queries(&mut reg);
|
||||
crate::module_map::register_queries(&mut reg);
|
||||
reg
|
||||
}
|
||||
pub(crate) fn add<Q: imp::EvalQuery>(&mut self, q: Q, name: &'static str) {
|
||||
|
|
|
@ -7,7 +7,7 @@ use ra_syntax::{
|
|||
ast::{self, NameOwner, AstNode},
|
||||
text_utils::is_subrange
|
||||
};
|
||||
use {
|
||||
use crate::{
|
||||
FileId,
|
||||
imp::FileResolverImp,
|
||||
};
|
||||
|
@ -271,4 +271,4 @@ impl FnDescriptor {
|
|||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use ra_syntax::{
|
|||
ast::{self, NameOwner, ArgListOwner, Expr},
|
||||
};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
FileId, FileResolver, Query, Diagnostic, SourceChange, SourceFileEdit, Position, FileSystemEdit,
|
||||
JobToken, CrateGraph, CrateId,
|
||||
roots::{SourceRoot, ReadonlySourceRoot, WritableSourceRoot},
|
||||
|
@ -458,4 +458,4 @@ impl<'a> FnCallNode<'a> {
|
|||
FnCallNode::MethodCallExpr(expr) => expr.arg_list()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,16 +29,18 @@ use std::{
|
|||
|
||||
use relative_path::{RelativePath, RelativePathBuf};
|
||||
use ra_syntax::{File, TextRange, TextUnit, AtomEdit};
|
||||
use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp};
|
||||
use rustc_hash::FxHashMap;
|
||||
use crate::imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp};
|
||||
|
||||
pub use ra_editor::{
|
||||
StructureNode, LineIndex, FileSymbol,
|
||||
Runnable, RunnableKind, HighlightedRange, CompletionItem,
|
||||
Fold, FoldKind
|
||||
};
|
||||
pub use job::{JobToken, JobHandle};
|
||||
pub use descriptors::FnDescriptor;
|
||||
pub use crate::{
|
||||
job::{JobToken, JobHandle},
|
||||
descriptors::FnDescriptor,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct FileId(pub u32);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
use {
|
||||
use crate::{
|
||||
FileId,
|
||||
db::{
|
||||
Query, QueryRegistry, QueryCtx,
|
||||
|
@ -38,7 +38,7 @@ mod tests {
|
|||
use std::collections::HashMap;
|
||||
use im;
|
||||
use relative_path::{RelativePath, RelativePathBuf};
|
||||
use {
|
||||
use crate::{
|
||||
db::{Db},
|
||||
imp::FileResolverImp,
|
||||
FileId, FileResolver,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use std::sync::Arc;
|
||||
use ra_syntax::File;
|
||||
use ra_editor::LineIndex;
|
||||
use {
|
||||
use crate::{
|
||||
FileId,
|
||||
db::{Query, QueryCtx, QueryRegistry},
|
||||
symbol_index::SymbolIndex,
|
||||
};
|
||||
|
||||
pub(crate) use db::{file_text, file_set};
|
||||
pub(crate) use crate::db::{file_text, file_set};
|
||||
|
||||
pub(crate) fn file_syntax(ctx: QueryCtx, file_id: FileId) -> File {
|
||||
(&*ctx.get(FILE_SYNTAX, file_id)).clone()
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_hash::FxHashMap;
|
|||
use ra_editor::LineIndex;
|
||||
use ra_syntax::File;
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
FileId,
|
||||
imp::FileResolverImp,
|
||||
symbol_index::SymbolIndex,
|
||||
|
@ -62,23 +62,23 @@ impl WritableSourceRoot {
|
|||
|
||||
impl SourceRoot for WritableSourceRoot {
|
||||
fn module_tree(&self) -> Arc<ModuleTreeDescriptor> {
|
||||
self.db.make_query(::module_map::module_tree)
|
||||
self.db.make_query(crate::module_map::module_tree)
|
||||
}
|
||||
|
||||
fn contains(&self, file_id: FileId) -> bool {
|
||||
self.db.state().file_map.contains_key(&file_id)
|
||||
}
|
||||
fn lines(&self, file_id: FileId) -> Arc<LineIndex> {
|
||||
self.db.make_query(|ctx| ::queries::file_lines(ctx, file_id))
|
||||
self.db.make_query(|ctx| crate::queries::file_lines(ctx, file_id))
|
||||
}
|
||||
fn syntax(&self, file_id: FileId) -> File {
|
||||
self.db.make_query(|ctx| ::queries::file_syntax(ctx, file_id))
|
||||
self.db.make_query(|ctx| crate::queries::file_syntax(ctx, file_id))
|
||||
}
|
||||
fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) {
|
||||
self.db.make_query(|ctx| {
|
||||
let file_set = ::queries::file_set(ctx);
|
||||
let file_set = crate::queries::file_set(ctx);
|
||||
let syms = file_set.0.iter()
|
||||
.map(|file_id| ::queries::file_symbols(ctx, *file_id));
|
||||
.map(|file_id| crate::queries::file_symbols(ctx, *file_id));
|
||||
acc.extend(syms);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use ra_syntax::{
|
|||
};
|
||||
use fst::{self, Streamer};
|
||||
use rayon::prelude::*;
|
||||
use {Query, FileId, JobToken};
|
||||
use crate::{Query, FileId, JobToken};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct SymbolIndex {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "ra_lsp_server"
|
||||
version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
|
|
|
@ -7,7 +7,7 @@ use ra_editor::{LineIndex, LineCol, Edit, AtomEdit};
|
|||
use ra_syntax::{SyntaxKind, TextUnit, TextRange};
|
||||
use ra_analysis::{FileId, SourceChange, SourceFileEdit, FileSystemEdit};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
Result,
|
||||
server_world::ServerWorld,
|
||||
req,
|
||||
|
@ -299,7 +299,7 @@ pub fn to_location(
|
|||
Ok(loc)
|
||||
}
|
||||
|
||||
pub trait MapConvWith<'a>: Sized {
|
||||
pub trait MapConvWith<'a>: Sized + 'a {
|
||||
type Ctx;
|
||||
type Output;
|
||||
|
||||
|
@ -309,7 +309,7 @@ pub trait MapConvWith<'a>: Sized {
|
|||
}
|
||||
|
||||
impl<'a, I> MapConvWith<'a> for I
|
||||
where I: Iterator,
|
||||
where I: Iterator + 'a,
|
||||
I::Item: ConvWith
|
||||
{
|
||||
type Ctx = <I::Item as ConvWith>::Ctx;
|
||||
|
|
|
@ -34,5 +34,7 @@ mod project_model;
|
|||
pub mod thread_watcher;
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, ::failure::Error>;
|
||||
pub use caps::server_capabilities;
|
||||
pub use main_loop::main_loop;
|
||||
pub use crate::{
|
||||
main_loop::main_loop,
|
||||
caps::server_capabilities,
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ use ra_syntax::{
|
|||
text_utils::contains_offset_nonstrict
|
||||
};
|
||||
|
||||
use ::{
|
||||
use crate::{
|
||||
req::{self, Decoration}, Result,
|
||||
conv::{Conv, ConvWith, TryConvWith, MapConvWith, to_location},
|
||||
server_world::ServerWorld,
|
||||
|
|
|
@ -16,7 +16,7 @@ use gen_lsp_server::{
|
|||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
req,
|
||||
Result,
|
||||
vfs::{self, FileEvent},
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use cargo_metadata::{metadata_run, CargoOpt};
|
||||
use ra_syntax::SmolStr;
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
Result,
|
||||
thread_watcher::{Worker, ThreadWatcher},
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hash::FxHashMap;
|
|||
use languageserver_types::Url;
|
||||
use ra_analysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId, LibraryData, FileResolver};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
Result,
|
||||
path_map::{PathMap, Root},
|
||||
vfs::{FileEvent, FileEventKind},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::thread;
|
||||
use crossbeam_channel::{bounded, unbounded, Sender, Receiver};
|
||||
use drop_bomb::DropBomb;
|
||||
use Result;
|
||||
use crate::Result;
|
||||
|
||||
pub struct Worker<I, O> {
|
||||
pub inp: Sender<I>,
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
thread_watcher::{Worker, ThreadWatcher},
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ mod support;
|
|||
|
||||
use ra_lsp_server::req::{Runnables, RunnablesParams};
|
||||
|
||||
use support::project;
|
||||
use crate::support::project;
|
||||
|
||||
|
||||
const LOG: &'static str = "";
|
||||
|
|
|
@ -25,7 +25,7 @@ use ra_lsp_server::{main_loop, req, thread_watcher::{ThreadWatcher, Worker}};
|
|||
|
||||
pub fn project(fixture: &str) -> Server {
|
||||
static INIT: Once = Once::new();
|
||||
INIT.call_once(|| Logger::with_env_or_str(::LOG).start().unwrap());
|
||||
INIT.call_once(|| Logger::with_env_or_str(crate::LOG).start().unwrap());
|
||||
|
||||
let tmp_dir = TempDir::new("test-project")
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue