diff --git a/duchain/astredux.h b/duchain/astredux.h index 4ffdc0c..43e84f8 100644 --- a/duchain/astredux.h +++ b/duchain/astredux.h @@ -1,71 +1,92 @@ #ifndef ASTREDUX_H #define ASTREDUX_H extern "C" { enum RSNodeKind { Crate, Module, StructDecl, EnumDecl, TraitDecl, ImplDecl, TypeAliasDecl, FieldDecl, EnumVariantDecl, FunctionDecl, ParmDecl, VarDecl, Path, PathSegment, Block, Arm, Unexposed }; +enum RSDiagnosticLevel +{ + Info, + Note, + Warning, + Error, + Fatal +}; + enum RSVisitResult { Break, Continue, Recurse }; struct RSLocation { int line; int column; }; struct RSRange { RSLocation start; RSLocation end; }; struct RSCrate; struct RSNode; +struct RSDiagnostic; +struct RSDiagnosticIterator; typedef RSVisitResult (*CallbackFn)(RSNode *node, RSNode *parent, void *data); RSCrate *parse_crate(const char *name, const char *source); void destroy_crate(RSCrate *crate); RSNode *node_from_crate(RSCrate *crate); void destroy_node(RSNode *node); unsigned int node_get_id(RSNode *node); RSCrate *node_get_crate(RSNode *node); RSNodeKind node_get_kind(RSNode *node); const char *node_get_spelling_name(RSNode *node); RSRange node_get_spelling_range(RSNode *node); RSRange node_get_extent(RSNode *node); void destroy_string(const char *str); +RSDiagnosticIterator *crate_get_diagnostics(RSCrate *crate); +void destroy_diagnostic_iterator(RSDiagnosticIterator *iterator); + +RSDiagnostic *diagnostics_next(RSDiagnosticIterator *iterator); +void destroy_diagnostic(RSDiagnostic *diagnostic); + +RSDiagnosticLevel diagnostic_get_level(RSDiagnostic *diagnostic); +const char *diagnostic_get_message(RSDiagnostic *diagnostic); +RSRange diagnostic_get_primary_range(RSDiagnostic *diagnostic); + void visit_children(RSNode *node, CallbackFn callback, void *data); } #endif // ASTREDUX_H diff --git a/duchain/rustnode.h b/duchain/rustnode.h index 4929335..c2bd6be 100644 --- a/duchain/rustnode.h +++ b/duchain/rustnode.h @@ -1,56 +1,60 @@ #ifndef RUSTNODE_H #define RUSTNODE_H #include #include "astredux.h" #include "kdevrustduchain_export.h" namespace Rust { template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject { public: RustAllocatedObject(RustObjectType *object); ~RustAllocatedObject(); RustObjectType *data(); RustObjectType *operator *(); private: RustObjectType *object; }; template void noop_destructor(T *) {} using RustCrate = RustAllocatedObject; using RustOwnedNode = RustAllocatedObject; using RustString = RustAllocatedObject; +using RustDiagnostic = RustAllocatedObject; +using RustDiagnosticIterator = RustAllocatedObject; class KDEVRUSTDUCHAIN_EXPORT RustNode : public RustAllocatedObject { public: RustNode(RSNode *node); RustNode(RustOwnedNode &node); ~RustNode(); }; class KDEVRUSTDUCHAIN_EXPORT RustPath { public: explicit RustPath(RustNode *node); QString value; }; template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; +template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; +template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; template class KDEVRUSTDUCHAIN_EXPORT RustAllocatedObject; } #endif // RUSTNODE_H