Skip to content

Commit

Permalink
Add Diagnostic Error Codes (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Schottkyc137 authored Apr 6, 2024
1 parent 28d2e8b commit ce2d47a
Show file tree
Hide file tree
Showing 72 changed files with 1,965 additions and 538 deletions.
37 changes: 36 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions vhdl_lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dunce = "1"
pinned_vec = "0"
itertools = "0"
subst = "0.3.0"
strum = { version = "0.26.2", features = ["derive"] }

[dev-dependencies]
tempfile = "3"
Expand Down
16 changes: 8 additions & 8 deletions vhdl_lang/src/analysis/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use super::root::*;
pub(crate) use super::scope::Scope;
use crate::ast::*;
use crate::data::error_codes::ErrorCode;
use crate::data::*;
use crate::named_entity::*;
use crate::syntax::TokenAccess;
Expand Down Expand Up @@ -56,7 +57,7 @@ impl CircularDependencyError {
/// Pushes this error into a diagnostic handler.
pub fn push_into(self, diagnostics: &mut dyn DiagnosticHandler) {
if let Some(pos) = self.reference {
diagnostics.error(pos, "Found circular dependency");
diagnostics.push(Diagnostic::circular_dependency(pos));
}
}
}
Expand Down Expand Up @@ -382,16 +383,15 @@ impl<'a> AnalyzeContext<'a> {
if let Some(design) = DesignEnt::from_any(ent) {
return Ok(design);
} else {
// Almost impossible but better not fail silently
bail!(
diagnostics,
Diagnostic::error(
Diagnostic::internal(
pos,
format!(
"Found non-design {} unit within library {}",
ent.describe(),
library_name
),
)
)
);
}
Expand All @@ -403,9 +403,8 @@ impl<'a> AnalyzeContext<'a> {
diagnostics,
Diagnostic::error(
pos,
format!(
"No architecture '{architecture_name}' for entity '{library_name}.{entity_name}'"
),
format!("No architecture '{architecture_name}' for entity '{library_name}.{entity_name}'"),
ErrorCode::Unresolved,
)
);
}
Expand All @@ -428,7 +427,7 @@ impl<'a> AnalyzeContext<'a> {
} else {
bail!(
diagnostics,
Diagnostic::error(
Diagnostic::internal(
pos,
format!(
"Found non-design {} unit within library {}",
Expand All @@ -448,6 +447,7 @@ impl<'a> AnalyzeContext<'a> {
Diagnostic::error(
pos,
format!("No primary unit '{primary_name}' within library '{library_name}'"),
ErrorCode::Unresolved,
)
);
}
Expand Down
Loading

0 comments on commit ce2d47a

Please sign in to comment.