nixd
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
nixf::Diagnostic Class Reference

#include <Diagnostic.h>

Inheritance diagram for nixf::Diagnostic:
[legend]
Collaboration diagram for nixf::Diagnostic:
[legend]

Public Types

enum  Severity {
  DS_Fatal , DS_Error , DS_Warning , DS_Info ,
  DS_Hint
}
 

Public Member Functions

 Diagnostic (DiagnosticKind Kind, LexerCursorRange Range)
 Internal kind.
 
DiagnosticKind kind () const
 
const char * message () const override
 
virtual const char * sname () const
 
Notenote (Note::NoteKind Kind, LexerCursorRange Range)
 
const std::vector< Note > & notes () const
 
Fixfix (std::string Message)
 
const std::vector< Fix > & fixes () const
 
- Public Member Functions inherited from nixf::PartialDiagnostic
virtual ~PartialDiagnostic ()=default
 
PartialDiagnosticoperator<< (std::string Var)
 
std::string format () const
 
const std::vector< std::string > & args () const
 
std::vector< std::string > & args ()
 
void tag (DiagnosticTag Tag)
 
const std::vector< DiagnosticTag > & tags () const
 
LexerCursorRange range () const
 

Static Public Member Functions

static Severity severity (DiagnosticKind Kind)
 
static const char * message (DiagnosticKind Kind)
 
static const char * sname (DiagnosticKind Kind)
 
static std::optional< Diagnostic::DiagnosticKind > parseKind (std::string_view SName)
 Parse diagnostic "cname" to diagnostic id.
 

Additional Inherited Members

- Protected Member Functions inherited from nixf::PartialDiagnostic
 PartialDiagnostic ()=default
 
 PartialDiagnostic (LexerCursorRange Range)
 

Detailed Description

The super class for all diagnostics. concret diagnostic types are defined in Diagnostic*.inc

Definition at line 147 of file Diagnostic.h.

Member Enumeration Documentation

◆ Severity

Each diagnostic contains a severity field, should be "Fatal", "Error" or "Warning" this will affect the eval process.

"Warning" – just a warning.

Enumerator
DS_Fatal 

shouldn't eval the code, e.g. parsing error.

DS_Error 

trigger an error in nix, but we can recover & eval the code.

DS_Warning 

A warning.

DS_Info 

An information.

DS_Hint 

A hint. Hints are usually not rendered directly in some editor GUI So this is suitable for liveness analysis results. For example, "unused xxx"

Definition at line 154 of file Diagnostic.h.

Constructor & Destructor Documentation

◆ Diagnostic()

nixf::Diagnostic::Diagnostic ( DiagnosticKind Kind,
LexerCursorRange Range )
inline

Internal kind.

Definition at line 173 of file Diagnostic.h.

Member Function Documentation

◆ fix()

Fix & nixf::Diagnostic::fix ( std::string Message)
inline

◆ fixes()

const std::vector< Fix > & nixf::Diagnostic::fixes ( ) const
inline

Definition at line 207 of file Diagnostic.h.

◆ kind()

DiagnosticKind nixf::Diagnostic::kind ( ) const
inline

Definition at line 176 of file Diagnostic.h.

Referenced by message(), and sname().

◆ message() [1/2]

const char * nixf::Diagnostic::message ( ) const
inlineoverridevirtual

Implements nixf::PartialDiagnostic.

Definition at line 182 of file Diagnostic.h.

References kind(), and message().

Referenced by message().

◆ message() [2/2]

static const char * nixf::Diagnostic::message ( DiagnosticKind Kind)
static

◆ note()

Note & nixf::Diagnostic::note ( Note::NoteKind Kind,
LexerCursorRange Range )
inline

◆ notes()

const std::vector< Note > & nixf::Diagnostic::notes ( ) const
inline

Definition at line 201 of file Diagnostic.h.

◆ parseKind()

static std::optional< Diagnostic::DiagnosticKind > nixf::Diagnostic::parseKind ( std::string_view SName)
static

Parse diagnostic "cname" to diagnostic id.

◆ severity()

static Severity nixf::Diagnostic::severity ( DiagnosticKind Kind)
static

Referenced by nixd::getLSPSeverity().

◆ sname() [1/2]

virtual const char * nixf::Diagnostic::sname ( ) const
inlinevirtual

Definition at line 195 of file Diagnostic.h.

References kind(), and sname().

Referenced by sname().

◆ sname() [2/2]

static const char * nixf::Diagnostic::sname ( DiagnosticKind Kind)
static

Short name, switch name. There might be a human readable short name that controls the diagnostic For example, one may pass -Wno-dup-formal to suppress duplicated formals. A special case for parsing errors, generated from bison have the sname "bison"


The documentation for this class was generated from the following file: