mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Improve runnable annotations order, fix incorrect ignore detection
This commit is contained in:
parent
c46b32c449
commit
ee049b256a
1 changed files with 18 additions and 10 deletions
|
@ -50,25 +50,26 @@ pub(crate) fn annotations(
|
||||||
|
|
||||||
if config.annotate_runnables {
|
if config.annotate_runnables {
|
||||||
for runnable in runnables(db, file_id) {
|
for runnable in runnables(db, file_id) {
|
||||||
if !matches!(runnable.kind, RunnableKind::Bin) || !config.binary_target {
|
if should_skip_runnable(&runnable.kind, config.binary_target) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let action = runnable.action();
|
let action = runnable.action();
|
||||||
let range = runnable.nav.full_range;
|
let range = runnable.nav.full_range;
|
||||||
|
|
||||||
if config.run {
|
|
||||||
annotations.push(Annotation {
|
|
||||||
range,
|
|
||||||
// FIXME: This one allocates without reason if run is enabled, but debug is disabled
|
|
||||||
kind: AnnotationKind::Runnable { debug: false, runnable: runnable.clone() },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if action.debugee && config.debug {
|
if action.debugee && config.debug {
|
||||||
annotations.push(Annotation {
|
annotations.push(Annotation {
|
||||||
range,
|
range,
|
||||||
kind: AnnotationKind::Runnable { debug: true, runnable },
|
|
||||||
|
// FIXME: This one allocates without reason if run is enabled, but debug is disabled
|
||||||
|
kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.run {
|
||||||
|
annotations.push(Annotation {
|
||||||
|
range,
|
||||||
|
kind: AnnotationKind::Runnable { debug: false, runnable },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +145,13 @@ pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation)
|
||||||
annotation
|
annotation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn should_skip_runnable(kind: &RunnableKind, binary_target: bool) -> bool {
|
||||||
|
match kind {
|
||||||
|
RunnableKind::Bin => !binary_target,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ide_db::base_db::{FileId, FileRange};
|
use ide_db::base_db::{FileId, FileRange};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue