File indexing completed on 2024-05-12 05:52:03

0001 /*
0002     SPDX-FileCopyrightText: 2019 Mark Nauwelaerts <mark.nauwelaerts@gmail.com>
0003     SPDX-License-Identifier: MIT
0004 */
0005 #pragma once
0006 
0007 #include <KTextEditor/Range>
0008 #include <QString>
0009 #include <QUrl>
0010 #include <qmetatype.h>
0011 
0012 enum class DiagnosticSeverity {
0013     Unknown = 0,
0014     Error = 1,
0015     Warning = 2,
0016     Information = 3,
0017     Hint = 4,
0018 };
0019 Q_DECLARE_METATYPE(DiagnosticSeverity)
0020 
0021 struct SourceLocation {
0022     QUrl uri;
0023     KTextEditor::Range range;
0024 };
0025 
0026 struct DiagnosticRelatedInformation {
0027     // empty url / invalid range when absent
0028     SourceLocation location;
0029     QString message;
0030 };
0031 
0032 struct Diagnostic {
0033     KTextEditor::Range range;
0034     DiagnosticSeverity severity;
0035     QString code;
0036     QString source;
0037     QString message;
0038     QList<DiagnosticRelatedInformation> relatedInformation;
0039 };
0040 Q_DECLARE_METATYPE(Diagnostic)
0041 
0042 struct FileDiagnostics {
0043     QUrl uri;
0044     QList<Diagnostic> diagnostics;
0045 };
0046 Q_DECLARE_METATYPE(FileDiagnostics)
0047 
0048 struct DiagnosticFix {
0049     QString fixTitle;
0050     std::function<void()> fixCallback;
0051 };
0052 Q_DECLARE_METATYPE(DiagnosticFix)