Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning suppression #4459

Closed
wants to merge 62 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift click to select a range
05def04
initial diagnostic identifiers
PgBiel Jun 4, 2024
f895896
warn identifier as string, categories
PgBiel Jun 5, 2024
fe860f8
initial attached comment detection
PgBiel Jun 11, 2024
e196e45
basic suppression detection
PgBiel Jun 12, 2024
3823f56
initial attempt at a local sink on call
PgBiel Jun 14, 2024
26ae1d3
fix local sink on call
PgBiel Jun 14, 2024
e69c58a
fix decorator lookup next to the span itself
PgBiel Jun 14, 2024
b559fc2
create Engine::tracepoint
PgBiel Jun 14, 2024
33588ab
add and use Sink::extend_tracked
PgBiel Jun 14, 2024
6f3166d
fix deduplication of warnings with different tracepoints
PgBiel Jun 14, 2024
849bb63
decorator syntax
PgBiel Jun 7, 2024
1623a91
initial decorator lexing
PgBiel Jun 10, 2024
ad6cc41
fix decorator lexing with wrong offsets
PgBiel Jun 18, 2024
9f9ba7b
separate DecoratorMarker from Decorator
PgBiel Jun 10, 2024
3e69560
initial decorator parsing in markup
PgBiel Jun 10, 2024
9f9e877
use lexer subtrees to parse decorators
PgBiel Jun 21, 2024
fdfd880
add decorator tests
PgBiel Jun 21, 2024
16859f5
search for 'allow' decorators
PgBiel Jun 21, 2024
a1d5861
don't swallow newlines in decorator lexing
PgBiel Jun 21, 2024
c3c3ea9
allow same line decorator search
PgBiel Jun 21, 2024
b318b0a
satisfy clippy
PgBiel Jun 21, 2024
a320e92
lexer now returns nodes
PgBiel Jun 21, 2024
7f1e2fc
more decorator tests
PgBiel Jun 21, 2024
910af83
proper decorator parsing
PgBiel Jun 24, 2024
acdd33c
remove redundant '-' identifier check
PgBiel Jun 24, 2024
c7d97a7
add doc comment regarding lexer subtrees
PgBiel Jun 24, 2024
d35a563
use proper name for paren tokens
PgBiel Jun 24, 2024
14dfb3f
create DecoratorMarker and DecoratorName
PgBiel Jun 24, 2024
65dc277
minor decorator lexing improvements
PgBiel Jun 25, 2024
1b5c6e8
no rendering in tests
PgBiel Jun 26, 2024
afaa45e
improve identifier naming, remove error id
PgBiel Jun 26, 2024
eec6a3a
diag ids: remove categories, improve docs
PgBiel Jun 26, 2024
05a40ed
lexer: make 'take_error' internal
PgBiel Jun 26, 2024
ecb0ee5
fix newline counting
PgBiel Jun 26, 2024
181c633
improve tree search
PgBiel Jun 27, 2024
866c536
simplify decorator arguments in the AST
PgBiel Jun 27, 2024
c96bf9a
dot
PgBiel Jun 27, 2024
eebd7f4
test allow with context
PgBiel Jun 27, 2024
9b311c1
add suppress on tracepoint test
PgBiel Jun 27, 2024
f8730b0
add test for decorator at end of line
PgBiel Jun 27, 2024
a74bbd8
current_kind -> current
PgBiel Jul 15, 2024
5b05e2d
Merge branch 'main' into warn-suppression
PgBiel Jul 15, 2024
19f3047
improve comments and formatting
PgBiel Jul 15, 2024
70d7e46
improve warning suppression check
PgBiel Jul 15, 2024
fd410f2
fix tests for now
PgBiel Jul 15, 2024
629375a
move around some sink functions
PgBiel Jul 15, 2024
2b442ea
remove inner node 'capped_newlines' field
PgBiel Jul 15, 2024
c1bb41d
new decorator syntax: '// @'
PgBiel Jul 15, 2024
0fb417d
add test for decorator in decorator
PgBiel Jul 16, 2024
fb77128
decorator -> annotation
PgBiel Jul 16, 2024
a5d36d6
fix annotation syntax in comments
PgBiel Jul 16, 2024
457892c
improve some var names
PgBiel Jul 16, 2024
c4c7cfc
Merge branch 'main' into warn-suppression
PgBiel Jul 22, 2024
5d60e48
use picostr for identifiers
PgBiel Jul 22, 2024
b866e58
add deprecated id for deprecations
PgBiel Jul 22, 2024
c8994d0
initial changes towards simpler syntax
PgBiel Jul 22, 2024
71f3e67
update tests with new syntax
PgBiel Jul 22, 2024
bab391a
Merge branch 'main' into warn-suppression
PgBiel Jul 23, 2024
e105cd1
improve errors in annotations
PgBiel Jul 23, 2024
46e4fbf
initial improvements to allow multiline annotations
PgBiel Jul 23, 2024
93bd46d
add parenthesized annotation linebreak support
PgBiel Jul 23, 2024
af7e258
apply suggested improvements
PgBiel Jul 29, 2024
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
Prev Previous commit
Next Next commit
add and use Sink::extend_tracked
avoids an unnecessary sink extension if the sink is empty
  • Loading branch information
PgBiel committed Jun 26, 2024
commit 33588ab2396d1798e9c4166653e41a38a086f21b
32 changes: 16 additions & 16 deletions crates/typst/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 79,7 @@ impl Engine<'_> {

// Apply the subsinks to the outer sink.
for (_, sink) in &mut pairs {
let sink = std::mem::take(sink);
self.sink.extend(sink.delayed, sink.warnings, sink.values);
Sink::extend_tracked(&mut self.sink, std::mem::take(sink));
}

pairs.into_iter().map(|(output, _)| output)
Expand Down Expand Up @@ -122,7 121,7 @@ impl Engine<'_> {
// Push the accumulated warnings and other fields back to the
// original sink after we have modified them. This is needed so the
// warnings are properly returned by compilation later.
self.sink.extend(sink.delayed, sink.warnings, sink.values);
Sink::extend_tracked(&mut self.sink, sink);

call_result
}
Expand Down Expand Up @@ -187,6 186,16 @@ impl Sink {
Self::default()
}

/// Extend the destination sink with the data from the source sink.
/// This calls a tracked function on the destination unless the source
/// is fully empty (which is usually the case).
pub fn extend_tracked(destination: &mut TrackedMut<'_, Self>, source: Sink) {
let Sink { delayed, warnings, values, .. } = source;
if !delayed.is_empty() || !warnings.is_empty() || !values.is_empty() {
destination.extend(delayed, warnings, values);
}
}

/// Get the stored delayed errors.
pub fn delayed(&mut self) -> EcoVec<SourceDiagnostic> {
std::mem::take(&mut self.delayed)
Expand All @@ -202,18 211,6 @@ impl Sink {
self.values
}

/// Takes and returns all fields from this sink:
/// delayed errors, warnings and traced values.
pub fn take(
self,
) -> (
EcoVec<SourceDiagnostic>,
EcoVec<SourceDiagnostic>,
EcoVec<(Value, Option<Styles>)>,
) {
(self.delayed, self.warnings, self.values)
}

/// Adds a tracepoint to all warnings outside the given span.
pub fn trace_warnings<F>(
PgBiel marked this conversation as resolved.
Show resolved Hide resolved
&mut self,
Expand Down Expand Up @@ -269,7 266,10 @@ impl Sink {
}

/// Extend from another sink.
pub fn extend(
/// Using `Sink::extend_tracked` is preferable as it avoids a call to this
PgBiel marked this conversation as resolved.
Show resolved Hide resolved
/// function if all arguments are empty, thus avoiding an unnecessary
/// tracked call in most cases.
fn extend(
&mut self,
delayed: EcoVec<SourceDiagnostic>,
warnings: EcoVec<SourceDiagnostic>,
Expand Down