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

feat(compiler): rework diagnostics to support multiple files #414

Merged
merged 50 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8c3cea3
Start designing error data model supporting multi-file
goto-bus-stop Jan 6, 2023
16f343c
update expected results
goto-bus-stop Jan 9, 2023
fe923ed
make new style diagnostic printable (without much context)
goto-bus-stop Jan 9, 2023
ba0cdf0
convert directive, enum, input object diagnostics
goto-bus-stop Jan 9, 2023
3637666
convert interface diagnostics
goto-bus-stop Jan 9, 2023
7257dd2
remove commented out attributes
goto-bus-stop Jan 10, 2023
01467c4
Copy HirNodeLocation instead of returning references
goto-bus-stop Jan 10, 2023
1eec425
Introduce DiagnosticLocation with source file info
goto-bus-stop Jan 11, 2023
76f7095
printing with ariadne
goto-bus-stop Jan 12, 2023
9736f03
Add colours
goto-bus-stop Jan 12, 2023
c4befaa
remove unnecessary copy
goto-bus-stop Jan 12, 2023
6438e09
support `help` messages
goto-bus-stop Jan 12, 2023
fdfb87c
Fix line number on main report label
goto-bus-stop Jan 13, 2023
8d16a10
avoid homedir name etc. in tests
goto-bus-stop Jan 13, 2023
edbc4be
Build the ariadne source cache once with salsa, then use FileIds ever…
goto-bus-stop Jan 13, 2023
bcf2c82
remove unreachable!()
goto-bus-stop Jan 13, 2023
ee72f09
Simplify SourceCache debug info
goto-bus-stop Jan 13, 2023
f77c62d
Update expect tests
goto-bus-stop Jan 13, 2023
a83af5a
Convert all UniqueDefinition diagnostics
goto-bus-stop Jan 13, 2023
abdf0d8
implement report severity
goto-bus-stop Jan 13, 2023
80e175d
Convert all MissingField diagnostics
goto-bus-stop Jan 13, 2023
e2b0a33
Remove unused ApolloDiagnostic members
goto-bus-stop Jan 13, 2023
9df9298
Convert all UniqueField diagnostics
goto-bus-stop Jan 13, 2023
fe50ec6
Convert all UndefinedDefinition diagnostics
goto-bus-stop Jan 13, 2023
17d4be0
Convert ScalarSpecificationURL diagnostic
goto-bus-stop Jan 13, 2023
a452519
Remove old UndefinedField, RecursiveDefinition, CapitalizedValue members
goto-bus-stop Jan 13, 2023
07017b8
Convert OutputType diagnostic
goto-bus-stop Jan 13, 2023
9a903dd
Address clippy
goto-bus-stop Jan 13, 2023
d5a19b1
Convert RootQueryOperationType diagnostic
goto-bus-stop Jan 13, 2023
4343d90
Convert BuiltInScalar diagnostic
goto-bus-stop Jan 13, 2023
32fa324
Convert UnusedVariable diagnostic
goto-bus-stop Jan 13, 2023
da5d7c0
Convert ObjectType diagnostic
goto-bus-stop Jan 13, 2023
1ce9993
Convert TransitiveImplementedInterface diagnostic
goto-bus-stop Jan 13, 2023
fb38f1e
Convert UniqueArgument diagnostic
goto-bus-stop Jan 13, 2023
879963c
Convert SyntaxError diagnostic
goto-bus-stop Jan 13, 2023
2085eb7
Remove backwards compat wrapper
goto-bus-stop Jan 13, 2023
8d37d3b
show operation type definition in the error when querying a nonexiste…
goto-bus-stop Jan 13, 2023
0460000
Remove miette dependency
goto-bus-stop Jan 13, 2023
229e9a8
Remove obsolete conversion impl from DiagnosticLocation
goto-bus-stop Jan 13, 2023
1b5a46e
Keep miette dependency for extend_db example
goto-bus-stop Jan 13, 2023
7f6061c
Use global file IDs – needs updates in tests to make it reliable
goto-bus-stop Jan 13, 2023
3d2a783
Use lowercase in diagnostic messages
goto-bus-stop Jan 17, 2023
2a26546
Merge branch 'main' into multi-file-errors
goto-bus-stop Jan 20, 2023
b00a20d
Merge branch 'main' into multi-file-errors
goto-bus-stop Jan 23, 2023
660517d
Merge branch 'main' into multi-file-errors
goto-bus-stop Jan 30, 2023
12e01b2
Port root instrospection validation
goto-bus-stop Jan 30, 2023
a385f4e
fix lint
goto-bus-stop Jan 30, 2023
deb5ef1
Use ariadne fork
goto-bus-stop Jan 30, 2023
7f0383c
Merge branch 'main' into multi-file-errors
goto-bus-stop Jan 30, 2023
5b38872
update file ids in diagnostics tests
goto-bus-stop Jan 30, 2023
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
5 changes: 3 additions & 2 deletions crates/apollo-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ edition = "2021"

[dependencies]
apollo-parser = { path = "../apollo-parser", version = "0.4.0" }
ariadne = { package = "apollo-ariadne", version = "0.2.0-alpha.0" }
indexmap = "1.9.2"
rowan = "0.15.5"
salsa = "0.16.1"
ordered-float = { version = "2.10.0", features = ["std"] }
miette = { version = "5.5.0", features = ["fancy"] }
thiserror = "1.0.31"

[target.'cfg(target_arch = "wasm32")'.dependencies]
uuid = { version = "1.1", features = ["serde", "v4", "js"] }

[dev-dependencies]
expect-test = "1.1"
anyhow = "1.0"
expect-test = "1.1"
miette = "5.0"
notify = "4.0.0"
criterion = "0.3.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ query getDogName {
name
}
}
}
doesNotExist
}
2 changes: 1 addition & 1 deletion crates/apollo-compiler/examples/documents/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ type Cat implements Pet {

union CatOrDog = Cat | Dog
union DogOrHuman = Dog | Human
union HumanOrAlien = Human | Alien
union HumanOrAlien = Human | Alien
20 changes: 14 additions & 6 deletions crates/apollo-compiler/src/database/ast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use apollo_parser::{Parser as ApolloParser, SyntaxTree};
use rowan::GreenNode;

use crate::{database::inputs::InputDatabase, diagnostics::SyntaxError, ApolloDiagnostic, FileId};
use crate::database::inputs::InputDatabase;
use crate::diagnostics::{ApolloDiagnostic, DiagnosticData, Label};
use crate::FileId;

#[salsa::query_group(AstStorage)]
pub trait AstDatabase: InputDatabase {
Expand Down Expand Up @@ -46,11 +48,17 @@ fn syntax_errors(db: &dyn AstDatabase) -> Vec<ApolloDiagnostic> {
.errors()
.into_iter()
.map(|err| {
ApolloDiagnostic::SyntaxError(SyntaxError {
src: db.source_code(file_id),
span: (err.index(), err.data().len()).into(), // (offset, length of error token)
message: err.message().into(),
})
ApolloDiagnostic::new(
db,
(file_id, err.index(), err.data().len()).into(),
DiagnosticData::SyntaxError {
message: err.message().into(),
},
)
.label(Label::new(
(file_id, err.index(), err.data().len()),
err.message(),
))
})
.collect::<Vec<ApolloDiagnostic>>()
})
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/database/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub(crate) fn operation_definition_variables(
.iter()
.map(|v| Variable {
name: v.name().to_owned(),
loc: *v.loc(),
loc: v.loc(),
})
.collect();
Arc::new(vars)
Expand Down
Loading