Files
modeling-app/rust/kcl-lib/src/lint/rule.rs

230 lines
6.0 KiB
Rust
Raw Normal View History

get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
use anyhow::Result;
use schemars::JsonSchema;
use serde::Serialize;
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
use tower_lsp::lsp_types::{Diagnostic, DiagnosticSeverity};
use crate::{lsp::IntoDiagnostic, walk::Node, SourceRange};
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
/// Check the provided AST for any found rule violations.
///
/// The Rule trait is automatically implemented for a few other types,
/// but it can also be manually implemented as required.
pub trait Rule<'a> {
/// Check the AST at this specific node for any Finding(s).
fn check(&self, node: Node<'a>) -> Result<Vec<Discovered>>;
}
impl<'a, FnT> Rule<'a> for FnT
where
FnT: Fn(Node<'a>) -> Result<Vec<Discovered>>,
{
fn check(&self, n: Node<'a>) -> Result<Vec<Discovered>> {
self(n)
}
}
/// Specific discovered lint rule Violation of a particular Finding.
#[derive(Clone, Debug, ts_rs::TS, Serialize, JsonSchema)]
#[ts(export)]
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
#[serde(rename_all = "camelCase")]
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
pub struct Discovered {
/// Zoo Lint Finding information.
pub finding: Finding,
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
/// Further information about the specific finding.
pub description: String,
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
/// Source code location.
pub pos: SourceRange,
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
/// Is this discovered issue overridden by the programmer?
pub overridden: bool,
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
}
#[cfg(feature = "pyo3")]
#[pyo3::pymethods]
impl Discovered {
#[getter]
pub fn finding(&self) -> Finding {
self.finding.clone()
}
#[getter]
pub fn description(&self) -> String {
self.description.clone()
}
#[getter]
pub fn pos(&self) -> (usize, usize) {
(self.pos.start(), self.pos.end())
}
#[getter]
pub fn overridden(&self) -> bool {
self.overridden
}
}
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
impl IntoDiagnostic for Discovered {
fn to_lsp_diagnostics(&self, code: &str) -> Vec<Diagnostic> {
(&self).to_lsp_diagnostics(code)
}
move back to using dashmap and cleanup heaps of code (#2834) * more Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * everything pre mutex locks Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove clones Signed-off-by: Jess Frazelle <github@jessfraz.com> * another clone Signed-off-by: Jess Frazelle <github@jessfraz.com> * iupdates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * progress Signed-off-by: Jess Frazelle <github@jessfraz.com> * more fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * test-utils Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * all features Signed-off-by: Jess Frazelle <github@jessfraz.com> * better naming Signed-off-by: Jess Frazelle <github@jessfraz.com> * upates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-06-27 15:43:49 -07:00
fn severity(&self) -> DiagnosticSeverity {
(&self).severity()
}
}
impl IntoDiagnostic for &Discovered {
fn to_lsp_diagnostics(&self, code: &str) -> Vec<Diagnostic> {
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
let message = self.finding.title.to_owned();
let source_range = self.pos;
vec![Diagnostic {
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
range: source_range.to_lsp_range(code),
move back to using dashmap and cleanup heaps of code (#2834) * more Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * everything pre mutex locks Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove clones Signed-off-by: Jess Frazelle <github@jessfraz.com> * another clone Signed-off-by: Jess Frazelle <github@jessfraz.com> * iupdates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * progress Signed-off-by: Jess Frazelle <github@jessfraz.com> * more fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * test-utils Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * all features Signed-off-by: Jess Frazelle <github@jessfraz.com> * better naming Signed-off-by: Jess Frazelle <github@jessfraz.com> * upates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-06-27 15:43:49 -07:00
severity: Some(self.severity()),
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
code: None,
// TODO: this is neat we can pass a URL to a help page here for this specific error.
code_description: None,
source: Some("lint".to_string()),
message,
related_information: None,
tags: None,
data: None,
}]
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
}
move back to using dashmap and cleanup heaps of code (#2834) * more Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * everything pre mutex locks Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove clones Signed-off-by: Jess Frazelle <github@jessfraz.com> * another clone Signed-off-by: Jess Frazelle <github@jessfraz.com> * iupdates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * progress Signed-off-by: Jess Frazelle <github@jessfraz.com> * more fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * test-utils Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * all features Signed-off-by: Jess Frazelle <github@jessfraz.com> * better naming Signed-off-by: Jess Frazelle <github@jessfraz.com> * upates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-06-27 15:43:49 -07:00
fn severity(&self) -> DiagnosticSeverity {
DiagnosticSeverity::INFORMATION
}
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
}
/// Abstract lint problem type.
#[derive(Clone, Debug, PartialEq, ts_rs::TS, Serialize, JsonSchema)]
#[ts(export)]
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
#[serde(rename_all = "camelCase")]
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
pub struct Finding {
/// Unique identifier for this particular issue.
pub code: &'static str,
/// Short one-line description of this issue.
pub title: &'static str,
/// Long human-readable description of this issue.
pub description: &'static str,
/// Is this discovered issue experimental?
pub experimental: bool,
}
impl Finding {
/// Create a new Discovered finding at the specific Position.
pub fn at(&self, description: String, pos: SourceRange) -> Discovered {
Discovered {
description,
finding: self.clone(),
pos,
overridden: false,
}
}
}
#[cfg(feature = "pyo3")]
#[pyo3::pymethods]
impl Finding {
#[getter]
pub fn code(&self) -> &'static str {
self.code
}
#[getter]
pub fn title(&self) -> &'static str {
self.title
}
#[getter]
pub fn description(&self) -> &'static str {
self.description
}
#[getter]
pub fn experimental(&self) -> bool {
self.experimental
}
}
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
macro_rules! def_finding {
( $code:ident, $title:expr, $description:expr ) => {
/// Generated Finding
pub const $code: Finding = $crate::lint::rule::finding!($code, $title, $description);
};
}
pub(crate) use def_finding;
macro_rules! finding {
( $code:ident, $title:expr, $description:expr ) => {
$crate::lint::rule::Finding {
code: stringify!($code),
title: $title,
description: $description,
experimental: false,
}
};
}
pub(crate) use finding;
#[cfg(test)]
pub(crate) use test::{assert_finding, assert_no_finding, test_finding, test_no_finding};
#[cfg(test)]
mod test {
macro_rules! assert_no_finding {
( $check:expr, $finding:expr, $kcl:expr ) => {
let prog = $crate::parsing::top_level_parse($kcl).unwrap();
for discovered_finding in prog.lint($check).unwrap() {
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
if discovered_finding.finding == $finding {
assert!(false, "Finding {:?} was emitted", $finding.code);
}
}
};
}
macro_rules! assert_finding {
( $check:expr, $finding:expr, $kcl:expr ) => {
let prog = $crate::parsing::top_level_parse($kcl).unwrap();
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
for discovered_finding in prog.lint($check).unwrap() {
Add in a prototype KCL linter (#2521) * Add in a prototype KCL linter This is a fork-and-replce of an experimental project I hacked up called "kcl-vet", which was mostly the same code. This integrates kcl-vet into the kcl_lib crate, which will let us use this from the zoo cli, as well as via wasm in the lsp. this contains the intial integration with the lsp, adding all lints as informational to start. I need to go back and clean some of this up (and merge some of this back into other parts of kcl_lib); but this has some pretty good progress already. Co-authored-by: jess@zoo.dev Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> * ty clippy :) * add in a lint test * add in some docstrings * whoops * sigh * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * uno reverse card * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * wtf stop it robot fuck * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit 5b18f3c0355d19b4816d060ce824003cd1107d41. * hurm * try harder to type slower * try harder? this all passes locally. * try this now * simplify, add debugging for trace * fix enter use * re-order again * reorder a bit more * enter * ok fine no other enters? * nerd * wip * move control of clearing to typescript * move result out * err check * remove log * remove clear * remove add to diag * THERE CAN BE ONLY ONE * _err * dedupe * Revert "dedupe" This reverts commit f66de88200feda3910059fef651c54b9a7935d08. * attempt to dedupe * clear diagnostics on mock execute, too * handle dupe diagnostics * fmt * dedupe tsc * == vs === * fix dedupe * return this to the wasm for now * clear the map every go around this is different than the old code isnce it won't republish --------- Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 19:23:35 -04:00
if discovered_finding.finding == $finding {
return;
}
}
assert!(false, "Finding {:?} was not emitted", $finding.code);
};
}
macro_rules! test_finding {
( $name:ident, $check:expr, $finding:expr, $kcl:expr ) => {
#[test]
fn $name() {
$crate::lint::rule::assert_finding!($check, $finding, $kcl);
}
};
}
macro_rules! test_no_finding {
( $name:ident, $check:expr, $finding:expr, $kcl:expr ) => {
#[test]
fn $name() {
$crate::lint::rule::assert_no_finding!($check, $finding, $kcl);
}
};
}
pub(crate) use assert_finding;
pub(crate) use assert_no_finding;
pub(crate) use test_finding;
pub(crate) use test_no_finding;
}