Skip to content

Commit

Permalink
fix: reimplement projectmainpath request
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Mar 25, 2024
1 parent eff14fd commit 2698017
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
23 changes: 20 additions & 3 deletions crates/sourcepawn_lsp/src/handlers/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use anyhow::Context;
use base_db::FileRange;
use lsp_types::{
SemanticTokensDeltaParams, SemanticTokensFullDeltaResult, SemanticTokensParams,
SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult,
SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, Url,
};
use stdx::format_to;

use crate::{
global_state::GlobalStateSnapshot,
lsp::{from_proto, to_proto},
lsp_ext::{
AnalyzerStatusParams, ItemTreeParams, PreprocessedDocumentParams, ProjectsGraphvizParams,
SyntaxTreeParams,
AnalyzerStatusParams, ItemTreeParams, PreprocessedDocumentParams, ProjectMainPathParams,
ProjectsGraphvizParams, SyntaxTreeParams,
},
};

Expand Down Expand Up @@ -246,3 +246,20 @@ pub(crate) fn handle_analyzer_status(
);
Ok(buf)
}

pub(crate) fn handle_project_main_path(
snap: GlobalStateSnapshot,
params: ProjectMainPathParams,
) -> anyhow::Result<Url> {
let uri = params
.uri
.ok_or_else(|| anyhow::anyhow!("No uri received in request"))?;
let file_id = from_proto::file_id(&snap, &uri)?;

snap.analysis
.projects_for_file(file_id)
.context("Failed to get project for file")?
.first()
.map(|it| to_proto::url(&snap, *it))
.ok_or_else(|| anyhow::anyhow!("No project found for file"))
}
1 change: 1 addition & 0 deletions crates/sourcepawn_lsp/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ impl GlobalState {
.on::<lsp_ext::PreprocessedDocument>(handlers::handle_preprocessed_document)
.on::<lsp_ext::ItemTree>(handlers::handle_item_tree)
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)
.on::<lsp_ext::ProjectMainPath>(handlers::handle_project_main_path)
.finish();
log::debug!("Handled request id: {:?}", req_id);
}
Expand Down
6 changes: 6 additions & 0 deletions editors/code/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Release Notes

## [7.2.5]

### Chore

- LSP version bump.

## [7.2.4]

### Chore
Expand Down
4 changes: 2 additions & 2 deletions editors/code/package-lock.json

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

2 changes: 1 addition & 1 deletion editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sourcepawn-vscode",
"displayName": "SourcePawn",
"description": "SourcePawn highlighting, autocompletion and much more",
"version": "7.2.4",
"version": "7.2.5",
"publisher": "Sarrus",
"main": "./dist/spIndex.js",
"icon": "sm.png",
Expand Down
2 changes: 1 addition & 1 deletion editors/code/package_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sourcepawn-vscode",
"displayName": "SourcePawn",
"description": "SourcePawn highlighting, autocompletion and much more",
"version": "7.2.4",
"version": "7.2.5",
"publisher": "Sarrus",
"main": "./dist/spIndex.js",
"icon": "sm.png",
Expand Down

0 comments on commit 2698017

Please sign in to comment.