Skip to content

Commit ce2d47a

Browse files
authored
Add Diagnostic Error Codes (#282)
1 parent 28d2e8b commit ce2d47a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1965
-538
lines changed

Cargo.lock

Lines changed: 36 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vhdl_lang/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dunce = "1"
2727
pinned_vec = "0"
2828
itertools = "0"
2929
subst = "0.3.0"
30+
strum = { version = "0.26.2", features = ["derive"] }
3031

3132
[dev-dependencies]
3233
tempfile = "3"

vhdl_lang/src/analysis/analyze.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use super::root::*;
88
pub(crate) use super::scope::Scope;
99
use crate::ast::*;
10+
use crate::data::error_codes::ErrorCode;
1011
use crate::data::*;
1112
use crate::named_entity::*;
1213
use crate::syntax::TokenAccess;
@@ -56,7 +57,7 @@ impl CircularDependencyError {
5657
/// Pushes this error into a diagnostic handler.
5758
pub fn push_into(self, diagnostics: &mut dyn DiagnosticHandler) {
5859
if let Some(pos) = self.reference {
59-
diagnostics.error(pos, "Found circular dependency");
60+
diagnostics.push(Diagnostic::circular_dependency(pos));
6061
}
6162
}
6263
}
@@ -382,16 +383,15 @@ impl<'a> AnalyzeContext<'a> {
382383
if let Some(design) = DesignEnt::from_any(ent) {
383384
return Ok(design);
384385
} else {
385-
// Almost impossible but better not fail silently
386386
bail!(
387387
diagnostics,
388-
Diagnostic::error(
388+
Diagnostic::internal(
389389
pos,
390390
format!(
391391
"Found non-design {} unit within library {}",
392392
ent.describe(),
393393
library_name
394-
),
394+
)
395395
)
396396
);
397397
}
@@ -403,9 +403,8 @@ impl<'a> AnalyzeContext<'a> {
403403
diagnostics,
404404
Diagnostic::error(
405405
pos,
406-
format!(
407-
"No architecture '{architecture_name}' for entity '{library_name}.{entity_name}'"
408-
),
406+
format!("No architecture '{architecture_name}' for entity '{library_name}.{entity_name}'"),
407+
ErrorCode::Unresolved,
409408
)
410409
);
411410
}
@@ -428,7 +427,7 @@ impl<'a> AnalyzeContext<'a> {
428427
} else {
429428
bail!(
430429
diagnostics,
431-
Diagnostic::error(
430+
Diagnostic::internal(
432431
pos,
433432
format!(
434433
"Found non-design {} unit within library {}",
@@ -448,6 +447,7 @@ impl<'a> AnalyzeContext<'a> {
448447
Diagnostic::error(
449448
pos,
450449
format!("No primary unit '{primary_name}' within library '{library_name}'"),
450+
ErrorCode::Unresolved,
451451
)
452452
);
453453
}

0 commit comments

Comments
 (0)