Skip to content

Commit

Permalink
chore: re-export the items needed for the lsp from the fm crate inste…
Browse files Browse the repository at this point in the history
…ad of importing codespan_reporting (#3757)

# Description

This is a small change to control the scope of what the lsp touches and
to see what the fm crate is offering to other crates in this workspace.

codespan_reporting is needed because the fm crate is using codespan

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
kevaundray authored Dec 11, 2023
1 parent 1c66b24 commit 010fdb6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions compiler/fm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ mod file_map;
mod file_reader;

pub use file_map::{File, FileId, FileMap, PathString};

// Re-export for the lsp
pub use codespan_reporting::files as codespan_files;

use file_reader::is_stdlib_asset;
pub use file_reader::FileReader;

Expand Down
1 change: 0 additions & 1 deletion tooling/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ license.workspace = true
[dependencies]
acvm.workspace = true
codespan-lsp.workspace = true
codespan-reporting.workspace = true
lsp-types.workspace = true
nargo.workspace = true
nargo_fmt.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use async_lsp::{
router::Router, AnyEvent, AnyNotification, AnyRequest, ClientSocket, Error, LspService,
ResponseError,
};
use codespan_reporting::files;
use fm::codespan_files as files;
use noirc_frontend::{
graph::{CrateId, CrateName},
hir::{Context, FunctionNameMatch},
Expand Down
6 changes: 3 additions & 3 deletions tooling/lsp/src/requests/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::{self, Future};

use crate::{types::GotoDefinitionResult, LspState};
use async_lsp::{ErrorCode, LanguageClient, ResponseError};
use codespan_reporting::files::Error;
use fm::codespan_files::Error;
use lsp_types::{GotoDefinitionParams, GotoDefinitionResponse, Location};
use lsp_types::{Position, Url};
use nargo_toml::{find_package_manifest, resolve_workspace_from_toml, PackageSelection};
Expand Down Expand Up @@ -98,7 +98,7 @@ fn to_lsp_location<'a, F>(
definition_span: noirc_errors::Span,
) -> Option<Location>
where
F: codespan_reporting::files::Files<'a> + ?Sized,
F: fm::codespan_files::Files<'a> + ?Sized,
{
let range = crate::byte_span_to_range(files, file_id, definition_span.into())?;
let file_name = files.name(file_id).ok()?;
Expand All @@ -115,7 +115,7 @@ pub(crate) fn position_to_byte_index<'a, F>(
position: &Position,
) -> Result<usize, Error>
where
F: codespan_reporting::files::Files<'a> + ?Sized,
F: fm::codespan_files::Files<'a> + ?Sized,
{
let source = files.source(file_id)?;
let source = source.as_ref();
Expand Down

0 comments on commit 010fdb6

Please sign in to comment.