Skip to content

Commit e61bdb7

Browse files
committed
Initial implementation
1 parent 812eccb commit e61bdb7

File tree

10 files changed

+935
-21
lines changed

10 files changed

+935
-21
lines changed

vhdl_lang/src/ast/search.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,24 @@ impl Search for SensitivityList {
508508
}
509509
}
510510

511+
impl Search for ProcessStatement {
512+
fn search(&self, ctx: &dyn TokenAccess, searcher: &mut impl Searcher) -> SearchResult {
513+
let ProcessStatement {
514+
postponed: _,
515+
sensitivity_list,
516+
decl,
517+
statements,
518+
end_label_pos: _,
519+
..
520+
} = self;
521+
if let Some(sensitivity_list) = sensitivity_list {
522+
return_if_found!(sensitivity_list.item.search(ctx, searcher));
523+
}
524+
return_if_found!(decl.search(ctx, searcher));
525+
statements.search(ctx, searcher)
526+
}
527+
}
528+
511529
impl Search for LabeledConcurrentStatement {
512530
fn search(&self, ctx: &dyn TokenAccess, searcher: &mut impl Searcher) -> SearchResult {
513531
return_if_found!(searcher
@@ -523,19 +541,7 @@ impl Search for LabeledConcurrentStatement {
523541
return_if_found!(block.statements.search(ctx, searcher));
524542
}
525543
ConcurrentStatement::Process(ref process) => {
526-
let ProcessStatement {
527-
postponed: _,
528-
sensitivity_list,
529-
decl,
530-
statements,
531-
end_label_pos: _,
532-
..
533-
} = process;
534-
if let Some(sensitivity_list) = sensitivity_list {
535-
return_if_found!(sensitivity_list.item.search(ctx, searcher));
536-
}
537-
return_if_found!(decl.search(ctx, searcher));
538-
return_if_found!(statements.search(ctx, searcher));
544+
return_if_found!(process.search(ctx, searcher));
539545
}
540546
ConcurrentStatement::ForGenerate(ref gen) => {
541547
return_if_found!(searcher

vhdl_lang/src/data/error_codes.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,33 @@ pub enum ErrorCode {
410410
/// ```
411411
UnassociatedContext,
412412

413+
/// A signal is missing in the sensitivity list
414+
///
415+
/// # Example
416+
/// ```vhdl
417+
/// foo: process(y) is
418+
/// begin
419+
/// bar <= x;
420+
/// end;
421+
/// ```
422+
///
423+
/// The signal `x` is read by the process `foo`, but it is not part
424+
/// of the sensitivity list.
425+
MissingInSensitivityList,
426+
427+
/// A signal is present in a sensitivity list, but never used
428+
///
429+
/// # Example
430+
/// ```vhdl
431+
/// foo: process(x, y) is
432+
/// begin
433+
/// bar <= x;
434+
/// end;
435+
/// ```
436+
///
437+
/// Both signals `x` and `y` are specified in the process, but only x is read.
438+
SuperfluousInSensitivityList,
439+
413440
// Misc
414441
/// An internal error that signifies that some precondition within vhdl_lang wasn't met.
415442
/// If an error with this error code occurs,
@@ -494,7 +521,9 @@ impl Default for SeverityMap {
494521
| InvalidCall => Some(Error),
495522
Unused
496523
| UnnecessaryWorkLibrary
497-
| UnassociatedContext => Some(Warning),
524+
| UnassociatedContext
525+
| MissingInSensitivityList
526+
| SuperfluousInSensitivityList => Some(Warning),
498527
Internal => Some(Error),
499528
Related => Some(Hint)
500529
};

vhdl_lang/src/lint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
// Copyright (c) 2022, Olof Kraigher olof.kraigher@gmail.com
66

77
pub mod dead_code;
8+
pub mod sensitivity_list;

0 commit comments

Comments
 (0)