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
32 changes: 16 additions & 16 deletions crates/plotnik-cli/src/commands/debug/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn format_node_with_field(
let text = node
.utf8_text(source.as_bytes())
.unwrap_or("<invalid utf8>");
if text == kind {
return if text == kind {
format!("{}{}(\"{}\")", indent, field_prefix, escape_string(kind))
} else {
format!(
Expand All @@ -117,22 +117,22 @@ fn format_node_with_field(
kind,
escape_string(text)
)
}
} else {
let mut out = format!("{}{}({}", indent, field_prefix, kind);
for (child, child_field) in children {
out.push('\n');
out.push_str(&format_node_with_field(
child,
child_field,
source,
depth + 1,
include_anonymous,
));
}
out.push(')');
out
};
}

let mut out = format!("{}{}({}", indent, field_prefix, kind);
for (child, child_field) in children {
out.push('\n');
out.push_str(&format_node_with_field(
child,
child_field,
source,
depth + 1,
include_anonymous,
));
}
out.push(')');
out
}

fn escape_string(s: &str) -> String {
Expand Down
7 changes: 3 additions & 4 deletions crates/plotnik-lib/src/bytecode/emit/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,10 @@ impl<'a> TsEmitter<'a> {
let Some(type_def) = self.types.get(type_id) else {
return (type_id, false);
};
if type_def.type_kind() == Some(TypeKind::Optional) {
(QTypeId(type_def.data), true)
} else {
(type_id, false)
if type_def.type_kind() != Some(TypeKind::Optional) {
return (type_id, false);
}
(QTypeId(type_def.data), true)
}

fn needs_generated_name(&self, type_def: &TypeDef) -> bool {
Expand Down
27 changes: 14 additions & 13 deletions crates/plotnik-lib/src/diagnostics/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,21 @@ impl<'a> DiagnosticsPrinter<'a> {
.span(adjust_range(related.span.range, primary_content.len()))
.label(&related.message),
);
} else {
// Different file: create separate snippet
let related_content = self.sources.content(related.span.source);
let mut snippet = Snippet::source(related_content).line_start(1);
if let Some(name) = self.source_path(related.span.source) {
snippet = snippet.path(name);
}
snippet = snippet.annotation(
AnnotationKind::Context
.span(adjust_range(related.span.range, related_content.len()))
.label(&related.message),
);
cross_file_snippets.push(snippet);
continue;
}

// Different file: create separate snippet
let related_content = self.sources.content(related.span.source);
let mut snippet = Snippet::source(related_content).line_start(1);
if let Some(name) = self.source_path(related.span.source) {
snippet = snippet.path(name);
}
snippet = snippet.annotation(
AnnotationKind::Context
.span(adjust_range(related.span.range, related_content.len()))
.label(&related.message),
);
cross_file_snippets.push(snippet);
}

let level = severity_to_level(diag.severity());
Expand Down