Skip to content

Commit e1cc71e

Browse files
committed
first commit for dfa messagestyle
1 parent 24a4107 commit e1cc71e

7 files changed

Lines changed: 522 additions & 4 deletions

File tree

compiler/src/dmd/cli.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,15 @@ dmd -cov -unittest myprog.d
901901
Option("vcolumns",
902902
"print character (column) numbers in diagnostics"
903903
),
904-
Option("verror-style=[digitalmars|gnu|sarif]",
904+
Option("verror-style=[digitalmars|gnu|sarif|dfa]",
905905
"set the style for file/line number annotations on compiler messages",
906906
`Set the style for file/line number annotations on compiler messages,
907907
where:
908908
$(DL
909909
$(DT digitalmars)$(DD 'file(line[,column]): message'. This is the default.)
910910
$(DT gnu)$(DD 'file:line[:column]: message', conforming to the GNU standard used by gcc and clang.)
911911
$(DT sarif)$(DD 'Generates JSON output conforming to the SARIF (Static Analysis Results Interchange Format) standard, useful for integration with tools like GitHub and other SARIF readers.')
912+
$(DT dfa)$(DD 'DFA messagestyle under construction.')
912913
)`,
913914
),
914915
Option("verror-supplements=<num>",

compiler/src/dmd/diagreport/defs.d

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module dmd.diagreport.defs;
2+
3+
/**
4+
Defines the vertical state of a diagnostic on a given line for drawing purposes.
5+
This enumeration captures the vertical state machine logic for a single diagnostic span.
6+
*/
7+
enum LineClassification
8+
{
9+
/// The line is not part of the diagnostic span.
10+
Inactive,
11+
/// The line is the start of the span and continues below. Implies the previous line was Inactive.
12+
SpanStart,
13+
/// The line is between the start and end. Implies the previous line and next line are Active.
14+
SpanContinue,
15+
/// The line is the end of the span and no other active diagnostics follow it. Implies the next line is Inactive.
16+
SpanEnd,
17+
/// The span starts and ends on the same line (a one-line diagnostic).
18+
SpanStartEnd
19+
}
20+
21+
struct Diagnostic
22+
{
23+
/// The line number where the diagnostic span begins (inclusive).
24+
int start;
25+
/// The line number where the diagnostic span ends (inclusive).
26+
int end;
27+
28+
Message startMessage;
29+
Message endMessage;
30+
31+
size_t id;
32+
33+
size_t offset()
34+
{
35+
return originalOffset;
36+
}
37+
38+
package:
39+
size_t originalOffset;
40+
int column;
41+
}
42+
43+
struct Message
44+
{
45+
int startColumn, endColumn;
46+
bool isMultiline;
47+
48+
size_t id;
49+
}
50+
51+
struct Help
52+
{
53+
Diagnostic[] diagnostics;
54+
55+
Message startMessage;
56+
Message endMessage;
57+
58+
size_t id;
59+
}

0 commit comments

Comments
 (0)