-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c94bc08
commit cfcdcfe
Showing
10 changed files
with
120 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use parser::position::{Position, Range}; | ||
|
||
use super::location::LocationData; | ||
|
||
#[derive(Debug, PartialEq, Eq, Default)] | ||
pub struct DefinitionInfo { | ||
pub defined_at: Range, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Default)] | ||
pub struct ReferencesInfo { | ||
pub references: Vec<Range>, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Default)] | ||
pub struct DocumentInfo { | ||
pub definitions: LocationData<DefinitionInfo>, | ||
pub references: LocationData<ReferencesInfo>, | ||
} | ||
|
||
impl DocumentInfo { | ||
pub fn get_definition(&self, position: &Position) -> Option<Range> { | ||
self.definitions | ||
.get(position) | ||
.map(|def| def.entry.defined_at) | ||
} | ||
|
||
pub fn get_references(&self, position: &Position) -> Option<&Vec<Range>> { | ||
let def_at = self.get_definition(position)?; | ||
self.references | ||
.get(&def_at.start) | ||
.map(|entry| &entry.entry.references) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::TextDocumentPositionParams; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct ReferenceParams { | ||
#[serde(flatten)] | ||
pub text_position: TextDocumentPositionParams, | ||
|
||
pub context: ReferenceContext, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ReferenceContext { | ||
pub include_declaration: bool, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ edition = "2021" | |
|
||
[dependencies] | ||
thiserror = "1.0" | ||
serde = { version = "1.0", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters