Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cab6f1

Browse filesBrowse files
captbaritonefacebook-github-bot
authored andcommitted
Support column in go to definition (#4969)
Summary: Pull Request resolved: #4969 Test Plan: Build locally and checked out https://github.com/captbaritone/grats-relay-example In `.vscode/settings.json` I added: ` "relay.pathToRelay": "/Users/jeldredge/projects/relay/compiler/target/release/relay",` https://github.com/user-attachments/assets/271de17b-74f0-447d-8f26-8123bcce7bdb Reviewed By: evanyeung Differential Revision: D73594815 Pulled By: captbaritone fbshipit-source-id: f1f30288d1e47fdaa86d2406fd8b3c909cb93706
1 parent 1558652 commit 4cab6f1
Copy full SHA for 4cab6f1

3 files changed

+11-2Lines changed: 11 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎compiler/crates/relay-bin/src/main.rs‎

Copy file name to clipboardExpand all lines: compiler/crates/relay-bin/src/main.rs
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@ impl LSPExtraDataProvider for ExtraDataProvider {
409409
}
410410
let file_path = result[0];
411411
let line_number = result[1].parse::<u64>().unwrap() - 1;
412+
let column_number = result[2].parse::<u64>().unwrap_or(1_u64) - 1;
412413

413414
Ok(Some(FieldDefinitionSourceInfo {
414415
file_path: file_path.to_string(),
415416
line_number,
417+
column_number,
416418
is_local: true,
417419
}))
418420
}
Collapse file

‎compiler/crates/relay-lsp/src/goto_definition.rs‎

Copy file name to clipboardExpand all lines: compiler/crates/relay-lsp/src/goto_definition.rs
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ fn locate_type_definition(
202202
GotoDefinitionResponse::Scalar(get_location(
203203
&source_info.file_path,
204204
source_info.line_number,
205+
source_info.column_number,
205206
)?)
206207
} else {
207208
return Err(LSPRuntimeError::ExpectedError);
@@ -318,6 +319,7 @@ fn locate_field_definition(
318319
return Ok(GotoDefinitionResponse::Scalar(get_location(
319320
&source_info.file_path,
320321
source_info.line_number,
322+
source_info.column_number,
321323
)?));
322324
} else {
323325
error!(
@@ -345,10 +347,14 @@ fn locate_field_definition(
345347
.map_err(|_| LSPRuntimeError::ExpectedError)
346348
}
347349

348-
fn get_location(path: &str, line: u64) -> Result<lsp_types::Location, LSPRuntimeError> {
350+
fn get_location(
351+
path: &str,
352+
line: u64,
353+
column: u64,
354+
) -> Result<lsp_types::Location, LSPRuntimeError> {
349355
let start = lsp_types::Position {
350356
line: line as u32,
351-
character: 0,
357+
character: column as u32,
352358
};
353359
let range = lsp_types::Range { start, end: start };
354360

Collapse file

‎compiler/crates/relay-lsp/src/lsp_extra_data_provider.rs‎

Copy file name to clipboardExpand all lines: compiler/crates/relay-lsp/src/lsp_extra_data_provider.rs
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use serde::Serialize;
1212
pub struct FieldDefinitionSourceInfo {
1313
pub file_path: String,
1414
pub line_number: u64,
15+
pub column_number: u64,
1516
pub is_local: bool,
1617
}
1718

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.