1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187 | package Torello.JavaDoc.Messager;
import static Torello.Java.C.*;
import static Torello.JavaDoc.Messager.Where_Am_I.LABEL_COLOR;
import Torello.Java.UnreachableError;
import Torello.JavaDoc.Declaration;
/**
* This is an internally used class that handles the Text-Generation for the Error-Message Headers.
* <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=PRINT_HEADING>
*/
public class PrintHeading
{
// ********************************************************************************************
// ********************************************************************************************
// Constructor & Field
// ********************************************************************************************
// ********************************************************************************************
private final PrintRecord printRecord;
PrintHeading(final PrintRecord printRecord)
{ this.printRecord = printRecord; }
// ********************************************************************************************
// ********************************************************************************************
// This class *ONLY* public (well, actually, "Package-Private") method
// ********************************************************************************************
// ********************************************************************************************
void printHeadingIfNecessary(final Where_Am_I WHERE_AM_I)
{
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Print the Heading - File-Name & "Maybe" the Refl-Name
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
final boolean printedTheHeadingMomentsAgo;
if (this.printRecord.modeFileAndProc())
printedTheHeadingMomentsAgo = this.printFileHeadingIfNecessary();
else if (this.printRecord.modeFileProcAndDecl())
printedTheHeadingMomentsAgo = this.printDeclarationHeadingIfNecessary();
else throw new UnreachableError();
final boolean mustPrintProcessorName =
printedTheHeadingMomentsAgo
|| this.printRecord.whereAmIChanged(WHERE_AM_I);
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Print the Processor and / or the Sub-Processor (Where_Am_I)
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
final int indentation = this.printRecord.getIndentation();
// POINT-OF-INTEREST: This is the only line **anywhere** inside this entire giant project
// that invokes 'messagerString'
//
// FINALLY: NOTE THERE IS A '-4' == PROC-HEADING is "-4" !!!
if (mustPrintProcessorName) this.printRecord.sb
.append(WHERE_AM_I.messagerString(indentation - 4))
.append('\n');
this.printRecord.setPreviouseWhereAmI(WHERE_AM_I);
}
// ********************************************************************************************
// ********************************************************************************************
// TWO PRIVATE METHODS
// ********************************************************************************************
// ********************************************************************************************
// RETURNS: TRUE or FALSE dependant on whether the File-Name was printed
private boolean printFileHeadingIfNecessary()
{
if (this.printRecord.alreadyPrintedFileName())
// FALSE ==> The file heading was **NOT** printed!
return false;
this.printRecord.printingFileNameRightNow();
// There is at least one location where the "setCurrentFileName" sets a Directory
// The text that this messager prints when the 'Messager.setCurrentFileName' ends with
// the System File-Separator is slightly different than it is for a file.
final String fileOrDir = this.printRecord.isFileOrDir();
final String i = this.printRecord.fodIndentation();
this.printRecord.sb.append(
this.printRecord.VERBOSITY_LEVEL_NEW_LINE +
LABEL_COLOR + " Processing" + fileOrDir + RESET + ' ' +
'[' + BYELLOW + this.printRecord.getFileName() + RESET + "]\n" +
((this.printRecord.getFileNameKind() != null)
? (i + this.printRecord.getFileNameKind() + '\n')
: "") +
'\n'
);
// TRUE ==> The file heading was just printed!
return true;
}
// RETURNS: TRUE or FALSE dependant on whether the Detail-Information was printed
private boolean printDeclarationHeadingIfNecessary()
{
printFileHeadingIfNecessary();
final Declaration declaration = this.printRecord.getDeclaration();
if (this.printRecord.alreadyPrintedDecl())
// FALSE ==> The detail heading was **NOT** printed!
return false;
this.printRecord.printingFirstDeclRightNow();
if (this.printRecord.topDescriptionAsDecl()) this.printRecord.sb.append(
" " + LABEL_COLOR + " Processing " + RESET +
" [" + BCYAN + "Main CIET/Type Description, at top" + RESET + "]\n" +
'\n'
);
else
{
// This check was added when the class "Location" was built. It is very much unknown
// how important this null-check is. Remember that an 'UnreachableError' is always
// better than a null-pointer exception.
if ( (declaration == null)
|| (declaration.location == null)
)
throw new UnreachableError();
final String ln1 = (declaration.location.signatureStartLine != -1)
? (
BCYAN + "Signature Line" + RESET +
": [" + BGREEN + declaration.location
.signatureStartLine +
RESET + "]"
)
: null;
final String ln2 = (declaration.location.jdcStartLine != -1)
? (
BCYAN + "JavaDoc Start Line" + RESET +
": [" + BGREEN + declaration.location.jdcStartLine +
RESET + "]"
)
: null;
final String line;
if (ln1 != null) line = ln1 + ((ln2 != null) ? (", " + ln2) : "");
else if (ln2 != null) line = ln2;
else line = "";
this.printRecord.sb.append(
" " + LABEL_COLOR + " Processing " + RESET + ' ' +
BCYAN + declaration.entity.toString() + RESET +
" Details Section " +
"for " + declaration.entity.toString() +
" [" + BRED + declaration.name + RESET + "], " +
line + '\n' +
'\n'
);
}
// TRUE ==> The Detail-Heading Message was printed
return true;
}
}
|