1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Error types for full-AST parsing and emission.
use miette::Diagnostic;
/// Errors from full-AST parse and emit operations.
#[non_exhaustive]
#[derive(Debug, thiserror::Error, Diagnostic)]
pub enum ParseError {
/// Tree-sitter failed to parse the source file.
#[error("tree-sitter parse failed for {path}")]
TreeSitterParse {
/// The file path that failed to parse.
path: String,
},
/// The source file's language could not be detected.
#[error("unknown language for file extension: {extension}")]
UnknownLanguage {
/// The unrecognized file extension.
extension: String,
},
/// Schema construction failed during AST walking.
#[error("schema construction failed: {reason}")]
SchemaConstruction {
/// Description of the construction failure.
reason: String,
},
/// Emission failed when converting a schema back to source text.
#[error("emit failed for protocol {protocol}: {reason}")]
EmitFailed {
/// The protocol being emitted.
protocol: String,
/// Description of the emit failure.
reason: String,
},
/// Theory extraction from grammar metadata failed.
#[error("theory extraction failed: {reason}")]
TheoryExtraction {
/// Description of the extraction failure.
reason: String,
},
/// JSON deserialization of node-types.json failed.
#[error("failed to parse node-types.json: {source}")]
NodeTypesJson {
/// The underlying JSON parse error.
#[source]
source: serde_json::Error,
},
/// A protocol error propagated from panproto-protocols.
#[error(transparent)]
Protocol(#[from] panproto_protocols::ProtocolError),
/// A tags-query failed to compile against a grammar.
///
/// Raised when `tree-sitter-tags` rejects the grammar's `queries/tags.scm`
/// (or a project-level override) for structural reasons: malformed
/// S-expression, unknown capture name outside the tags-query vocabulary,
/// or regex syntax error in a `#strip!` predicate.
#[error("scope-detection query failed to compile: {reason}")]
ScopeQueryCompile {
/// Underlying compiler error message.
reason: String,
},
}