Skip to content

Commit 0c88912

Browse files
authored
Merge pull request #73 from Bochlin/72-postponed-process-not-fully-supported
Check for postponed at end of process
2 parents ce51e67 + f091c2f commit 0c88912

File tree

4 files changed

+57
-4
lines changed

4 files changed

+57
-4
lines changed

vhdl_lang/src/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub struct SourceFile {
208208

209209
impl SourceFile {
210210
fn take_design_file(&mut self) -> DesignFile {
211-
std::mem::replace(&mut self.design_file, DesignFile::default())
211+
std::mem::take(&mut self.design_file)
212212
}
213213

214214
pub fn num_lines(&self) -> usize {

vhdl_lang/src/syntax/concurrent_statement.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ pub fn parse_process_statement(
196196
let decl = parse_declarative_part(stream, diagnostics, true)?;
197197
let (statements, end_token) = parse_labeled_sequential_statements(stream, diagnostics)?;
198198
try_token_kind!(end_token, End => {});
199+
if let Some(token) = stream.pop_if_kind(Postponed)? {
200+
if !postponed {
201+
diagnostics.push(Diagnostic::error(
202+
token,
203+
"'postponed' at the end of non-postponed process.",
204+
));
205+
}
206+
}
199207
stream.expect_kind(Process)?;
200208
// @TODO check name
201209
stream.pop_if_kind(Identifier)?;
@@ -961,6 +969,52 @@ end process;
961969
assert_eq!(stmt.statement, ConcurrentStatement::Process(process));
962970
}
963971

972+
#[test]
973+
fn test_postponed_process_statement_end_postponed() {
974+
let code = Code::new(
975+
"\
976+
postponed process
977+
begin
978+
end postponed process;
979+
",
980+
);
981+
let process = ProcessStatement {
982+
postponed: true,
983+
sensitivity_list: None,
984+
decl: vec![],
985+
statements: vec![],
986+
};
987+
let stmt = code.with_stream_no_diagnostics(parse_labeled_concurrent_statement);
988+
assert_eq!(stmt.label, None);
989+
assert_eq!(stmt.statement, ConcurrentStatement::Process(process));
990+
}
991+
992+
#[test]
993+
fn test_process_statement_end_postponed() {
994+
let code = Code::new(
995+
"\
996+
process is
997+
begin
998+
end postponed process;
999+
",
1000+
);
1001+
let (stmt, diagnostics) = code.with_stream_diagnostics(parse_labeled_concurrent_statement);
1002+
let process = ProcessStatement {
1003+
postponed: false,
1004+
sensitivity_list: None,
1005+
decl: Vec::new(),
1006+
statements: Vec::new(),
1007+
};
1008+
assert_eq!(
1009+
diagnostics,
1010+
vec![Diagnostic::error(
1011+
code.s1("postponed"),
1012+
"'postponed' at the end of non-postponed process."
1013+
)]
1014+
);
1015+
assert_eq!(stmt.statement, ConcurrentStatement::Process(process));
1016+
}
1017+
9641018
#[test]
9651019
fn test_process_statement_sensitivity() {
9661020
let code = Code::new(

vhdl_lang/src/syntax/design_unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn parse_package_body(
153153
}
154154

155155
fn take_context_clause(context_clause: &mut ContextClause) -> ContextClause {
156-
std::mem::replace(context_clause, ContextClause::default())
156+
std::mem::take(context_clause)
157157
}
158158

159159
fn context_item_message(context_item: &ContextItem, message: impl AsRef<str>) -> String {

vhdl_ls/src/vhdl_server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ impl<T: RpcChannel + Clone> InitializedVHDLServer<T> {
228228
}
229229
};
230230

231-
let mut files_with_notifications =
232-
std::mem::replace(&mut self.files_with_notifications, FnvHashMap::default());
231+
let mut files_with_notifications = std::mem::take(&mut self.files_with_notifications);
233232
for (file_uri, diagnostics) in diagnostics_by_uri(diagnostics).into_iter() {
234233
let mut lsp_diagnostics = Vec::new();
235234
for diagnostic in diagnostics {

0 commit comments

Comments
 (0)