Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[relay-lsp] Support go to definition within schema (extension) files #4627

Closed

Conversation

tobias-tengler
Copy link
Contributor

Depends on #4626

@@ -516,8 +523,26 @@ impl<TPerfLogger: PerfLogger + 'static, TSchemaDocumentation: SchemaDocumentatio
js_server.process_js_source(uri, text);
}

let source_location = SourceLocationKey::standalone(uri.path());
Copy link
Contributor Author

@tobias-tengler tobias-tengler Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use FileCategorizer to determine whether the file is a schema (extension) file

// First we check to see if this document has any GraphQL documents.
let embedded_sources = extract_graphql::extract(text);

let should_init_lsp_resources =
!embedded_sources.is_empty() || uri.as_str().ends_with(".graphql");
Copy link
Contributor Author

@tobias-tengler tobias-tengler Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use FileCategorizer result here as well

@@ -530,6 +555,13 @@ impl<TPerfLogger: PerfLogger + 'static, TSchemaDocumentation: SchemaDocumentatio
js_server.process_js_source(uri, full_text);
}

let source_location = SourceLocationKey::standalone(uri.path());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Ok(project_name.into())
}

fn get_file_contents(path: &Path) -> LSPRuntimeResult<String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

let file_path = uri
.to_file_path()
.map_err(|_| LSPRuntimeError::ExpectedError)?;
let text = get_file_contents(file_path.as_path())?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually implement a TextSource without reading from disk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants