Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 48 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "technique"
version = "0.4.3"
version = "0.4.5"
edition = "2021"
description = "A domain specific language for procedures."
authors = [ "Andrew Cowie" ]
Expand Down
3 changes: 3 additions & 0 deletions src/editor/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ impl TechniqueLanguageServer {
ParsingError::InvalidSubstep(_, _) => {
("Invalid substep".to_string(), DiagnosticSeverity::ERROR)
}
ParsingError::InvalidAttribute(_, _) => {
("Invalid attribute assignment".to_string(), DiagnosticSeverity::ERROR)
}
ParsingError::InvalidResponse(_, _) => {
("Invalid response".to_string(), DiagnosticSeverity::ERROR)
}
Expand Down
16 changes: 15 additions & 1 deletion src/formatting/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ pub fn render_procedure_declaration<'i>(procedure: &'i Procedure, renderer: &dyn
render_fragments(&sub.fragments, renderer)
}

pub fn render_scope<'i>(scope: &'i Scope, renderer: &dyn Render) -> String {
let mut sub = Formatter::new(78);
match scope {
Scope::AttributeBlock { attributes, .. } => {
// Render attributes without indentation for error messages
sub.append_attributes(attributes);
}
_ => {
panic!("Do not use for anything other than rendering Attribute line examples");
}
}
render_fragments(&sub.fragments, renderer)
}

/// Helper function to convert fragments to a styled string using a renderer
fn render_fragments<'i>(fragments: &[(Syntax, Cow<'i, str>)], renderer: &dyn Render) -> String {
let mut result = String::new();
Expand Down Expand Up @@ -806,6 +820,7 @@ impl<'i> Formatter<'i> {
attributes,
subscopes,
} => {
self.indent();
self.append_attributes(attributes);
self.add_fragment_reference(Syntax::Newline, "\n");

Expand Down Expand Up @@ -906,7 +921,6 @@ impl<'i> Formatter<'i> {
}

fn append_attributes(&mut self, attributes: &'i Vec<Attribute>) {
self.indent();
for (i, attribute) in attributes
.iter()
.enumerate()
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn main() {
.subcommand(
Command::new("language")
.about("Language Server Protocol integration for editors and IDEs.")
.hide(true)
.long_about("Run a Language Server Protocol (LSP) service \
for Technique documents. This accepts commands and code \
input via stdin and returns compilation errors and other \
Expand Down
4 changes: 2 additions & 2 deletions src/parsing/checks/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ making_coffee :
1. Do something { re peat() }
"#
.trim_ascii(),
ParsingError::InvalidFunction(39, 7),
ParsingError::InvalidCodeBlock(39, 10),
);
}

Expand All @@ -259,7 +259,7 @@ making_coffee :
1. Do something { re peat <thing>() }
"#
.trim_ascii(),
ParsingError::InvalidFunction(39, 15),
ParsingError::InvalidCodeBlock(39, 18),
);
}

Expand Down
Loading