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

chore(lsp): Remove profile code lens #6411

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

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

43 changes: 0 additions & 43 deletions compiler/noirc_errors/src/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use serde::Serializer;
use serde_with::serde_as;
use serde_with::DisplayFromStr;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::io::Read;
use std::io::Write;
use std::mem;
Expand Down Expand Up @@ -106,14 +105,6 @@ pub struct DebugInfo {
pub types: DebugTypes,
}

/// Holds OpCodes Counts for Acir and Brillig Opcodes
/// To be printed with `nargo info --profile-info`
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
pub struct OpCodesCount {
pub acir_size: usize,
pub brillig_size: usize,
}

impl DebugInfo {
pub fn new(
locations: BTreeMap<OpcodeLocation, Vec<Location>>,
Expand Down Expand Up @@ -147,38 +138,4 @@ impl DebugInfo {
pub fn opcode_location(&self, loc: &OpcodeLocation) -> Option<Vec<Location>> {
self.locations.get(loc).cloned()
}

pub fn count_span_opcodes(&self) -> HashMap<Location, OpCodesCount> {
let mut accumulator: HashMap<Location, Vec<&OpcodeLocation>> = HashMap::new();

for (opcode_location, locations) in self.locations.iter() {
for location in locations.iter() {
let opcodes = accumulator.entry(*location).or_default();
opcodes.push(opcode_location);
}
}

let counted_opcodes = accumulator
.iter()
.map(|(location, opcodes)| {
let acir_opcodes: Vec<_> = opcodes
.iter()
.filter(|opcode_location| matches!(opcode_location, OpcodeLocation::Acir(_)))
.collect();
let brillig_opcodes: Vec<_> = opcodes
.iter()
.filter(|opcode_location| {
matches!(opcode_location, OpcodeLocation::Brillig { .. })
})
.collect();
let opcodes_count = OpCodesCount {
acir_size: acir_opcodes.len(),
brillig_size: brillig_opcodes.len(),
};
(*location, opcodes_count)
})
.collect();

counted_opcodes
}
}
2 changes: 0 additions & 2 deletions tooling/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ nargo_toml.workspace = true
noirc_driver.workspace = true
noirc_errors.workspace = true
noirc_frontend.workspace = true
noirc_artifacts.workspace = true
serde.workspace = true
serde_json.workspace = true
strum = "0.24"
tower.workspace = true
async-lsp = { workspace = true, features = ["omni-trait"] }
serde_with = "3.2.0"
thiserror.workspace = true
fm.workspace = true
rayon.workspace = true
Expand Down
7 changes: 3 additions & 4 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ use requests::{
on_code_action_request, on_code_lens_request, on_completion_request,
on_document_symbol_request, on_formatting, on_goto_declaration_request,
on_goto_definition_request, on_goto_type_definition_request, on_hover_request, on_initialize,
on_inlay_hint_request, on_prepare_rename_request, on_profile_run_request,
on_references_request, on_rename_request, on_shutdown, on_signature_help_request,
on_test_run_request, on_tests_request, LspInitializationOptions,
on_inlay_hint_request, on_prepare_rename_request, on_references_request, on_rename_request,
on_shutdown, on_signature_help_request, on_test_run_request, on_tests_request,
LspInitializationOptions,
};
use serde_json::Value as JsonValue;
use thiserror::Error;
Expand Down Expand Up @@ -154,7 +154,6 @@ impl NargoLspService {
.request::<request::CodeLens, _>(on_code_lens_request)
.request::<request::NargoTests, _>(on_tests_request)
.request::<request::NargoTestRun, _>(on_test_run_request)
.request::<request::NargoProfileRun, _>(on_profile_run_request)
.request::<request::GotoDefinition, _>(on_goto_definition_request)
.request::<request::GotoDeclaration, _>(on_goto_declaration_request)
.request::<request::GotoTypeDefinition, _>(on_goto_type_definition_request)
Expand Down
14 changes: 0 additions & 14 deletions tooling/lsp/src/requests/code_lens_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const EXECUTE_CODELENS_TITLE: &str = "Execute";
const DEBUG_COMMAND: &str = "nargo.debug.dap";
const DEBUG_CODELENS_TITLE: &str = "Debug";

const PROFILE_COMMAND: &str = "nargo.profile";
const PROFILE_CODELENS_TITLE: &str = "Profile";

fn with_arrow(title: &str) -> String {
format!("{ARROW} {title}")
}
Expand Down Expand Up @@ -162,7 +159,6 @@ pub(crate) fn collect_lenses_for_package(
let internal_command_lenses = [
(INFO_CODELENS_TITLE, INFO_COMMAND),
(EXECUTE_CODELENS_TITLE, EXECUTE_COMMAND),
(PROFILE_CODELENS_TITLE, PROFILE_COMMAND),
(DEBUG_CODELENS_TITLE, DEBUG_COMMAND),
]
.map(|(title, command)| {
Expand Down Expand Up @@ -214,16 +210,6 @@ pub(crate) fn collect_lenses_for_package(
let info_lens = CodeLens { range, command: Some(info_command), data: None };

lenses.push(info_lens);

let profile_command = Command {
title: PROFILE_CODELENS_TITLE.to_string(),
command: PROFILE_COMMAND.into(),
arguments: Some(package_selection_args(workspace, package)),
};

let profile_lens = CodeLens { range, command: Some(profile_command), data: None };

lenses.push(profile_lens);
}
}

Expand Down
4 changes: 1 addition & 3 deletions tooling/lsp/src/requests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
mod goto_definition;
mod hover;
mod inlay_hint;
mod profile_run;
mod references;
mod rename;
mod signature_help;
Expand All @@ -56,8 +55,7 @@
code_lens_request::on_code_lens_request, completion::on_completion_request,
document_symbol::on_document_symbol_request, goto_declaration::on_goto_declaration_request,
goto_definition::on_goto_definition_request, goto_definition::on_goto_type_definition_request,
hover::on_hover_request, inlay_hint::on_inlay_hint_request,
profile_run::on_profile_run_request, references::on_references_request,
hover::on_hover_request, inlay_hint::on_inlay_hint_request, references::on_references_request,
rename::on_prepare_rename_request, rename::on_rename_request,
signature_help::on_signature_help_request, test_run::on_test_run_request,
tests::on_tests_request,
Expand Down Expand Up @@ -252,7 +250,7 @@
signature_help_provider: Some(lsp_types::OneOf::Right(
lsp_types::SignatureHelpOptions {
trigger_characters: Some(vec!["(".to_string(), ",".to_string()]),
retrigger_characters: None,

Check warning on line 253 in tooling/lsp/src/requests/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (retrigger)
work_done_progress_options: WorkDoneProgressOptions {
work_done_progress: None,
},
Expand Down
122 changes: 0 additions & 122 deletions tooling/lsp/src/requests/profile_run.rs

This file was deleted.

28 changes: 2 additions & 26 deletions tooling/lsp/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use fm::FileId;
use lsp_types::{
CodeActionOptions, CompletionOptions, DeclarationCapability, DefinitionOptions,
DocumentSymbolOptions, HoverOptions, InlayHintOptions, OneOf, ReferencesOptions, RenameOptions,
SignatureHelpOptions, TypeDefinitionProviderCapability,
};
use noirc_driver::DebugFile;
use noirc_errors::{debug_info::OpCodesCount, Location};
use noirc_frontend::graph::CrateName;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use std::collections::{BTreeMap, HashMap};

// Re-providing lsp_types that we don't need to override
pub(crate) use lsp_types::{
Expand All @@ -23,8 +18,8 @@ pub(crate) mod request {
use lsp_types::{request::Request, InitializeParams};

use super::{
InitializeResult, NargoProfileRunParams, NargoProfileRunResult, NargoTestRunParams,
NargoTestRunResult, NargoTestsParams, NargoTestsResult,
InitializeResult, NargoTestRunParams, NargoTestRunResult, NargoTestsParams,
NargoTestsResult,
};

// Re-providing lsp_types that we don't need to override
Expand Down Expand Up @@ -56,14 +51,6 @@ pub(crate) mod request {
type Result = NargoTestsResult;
const METHOD: &'static str = "nargo/tests";
}

#[derive(Debug)]
pub(crate) struct NargoProfileRun;
impl Request for NargoProfileRun {
type Params = NargoProfileRunParams;
type Result = NargoProfileRunResult;
const METHOD: &'static str = "nargo/profile/run";
}
}

pub(crate) mod notification {
Expand Down Expand Up @@ -253,17 +240,6 @@ pub(crate) struct NargoTestRunResult {
pub(crate) result: String,
pub(crate) message: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct NargoProfileRunParams {
pub(crate) package: CrateName,
}
#[serde_as]
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct NargoProfileRunResult {
pub(crate) file_map: BTreeMap<FileId, DebugFile>,
#[serde_as(as = "Vec<(_, _)>")]
pub(crate) opcodes_counts: HashMap<Location, OpCodesCount>,
}

pub(crate) type CodeLensResult = Option<Vec<CodeLens>>;
pub(crate) type GotoDefinitionResult = Option<lsp_types::GotoDefinitionResponse>;
Expand Down
Loading