envapsulate navigation target better

This commit is contained in:
Aleksey Kladov 2019-01-11 14:00:54 +03:00
parent 1d3d05d5d7
commit f9ed8d4d23
8 changed files with 102 additions and 96 deletions

View file

@ -34,9 +34,9 @@ mod syntax_highlighting;
use std::{fmt, sync::Arc};
use ra_syntax::{SmolStr, SourceFile, TreePtr, SyntaxKind, TextRange, TextUnit};
use ra_syntax::{SourceFile, TreePtr, TextRange, TextUnit};
use ra_text_edit::TextEdit;
use ra_db::{SyntaxDatabase, FilesDatabase, LocalSyntaxPtr, BaseDatabase};
use ra_db::{SyntaxDatabase, FilesDatabase, BaseDatabase};
use rayon::prelude::*;
use relative_path::RelativePathBuf;
use rustc_hash::FxHashMap;
@ -50,6 +50,7 @@ use crate::{
pub use crate::{
completion::{CompletionItem, CompletionItemKind, InsertText},
runnables::{Runnable, RunnableKind},
navigation_target::NavigationTarget,
};
pub use ra_ide_api_light::{
Fold, FoldKind, HighlightedRange, Severity, StructureNode,
@ -243,39 +244,6 @@ impl Query {
}
}
/// `NavigationTarget` represents and element in the editor's UI which you can
/// click on to navigate to a particular piece of code.
///
/// Typically, a `NavigationTarget` corresponds to some element in the source
/// code, like a function or a struct, but this is not strictly required.
#[derive(Debug, Clone)]
pub struct NavigationTarget {
file_id: FileId,
name: SmolStr,
kind: SyntaxKind,
range: TextRange,
// Should be DefId ideally
ptr: Option<LocalSyntaxPtr>,
}
impl NavigationTarget {
pub fn name(&self) -> &SmolStr {
&self.name
}
pub fn kind(&self) -> SyntaxKind {
self.kind
}
pub fn file_id(&self) -> FileId {
self.file_id
}
pub fn range(&self) -> TextRange {
self.range
}
}
#[derive(Debug)]
pub struct RangeInfo<T> {
pub range: TextRange,