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
188
189 | package Torello.JavaDoc.Annotations;
import static Torello.Java.C.RESET;
import static Torello.Java.C.BCYAN;
import Torello.JavaDoc.Messager.Messager;
import Torello.JavaDoc.Messager.MsgPrintTools;
import Torello.JavaDoc.Messager.MsgVerbose;
import Torello.JDUInternal.Miscellaneous.Where.JDUAnnotations;
import Torello.Java.ReadOnly.ReadOnlyList;
import Torello.Java.ReadOnly.ReadOnlyArrayList;
import Torello.Java.StrCSV;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.AssignmentTree;
import java.util.List;
/**
* An internally used data-record class used for storing all user-supplied annotation data
* associated with a single use / application of the {@link JavaScriptImport} annotation.
*
* @see Torello.JavaDoc.Annotations.JavaScriptImport
*/
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="MIRROR_JDHBI")
public class JSIMirror implements AnnotationMirror
{
// ********************************************************************************************
// ********************************************************************************************
// Public, Final, ReadOnly, Mirrored Fields
// ********************************************************************************************
// ********************************************************************************************
/** Holds data extracted from {@link JavaScriptImport#FileNames()}*/
public final ReadOnlyList<String> fileNames;
/** Holds data extracted from {@link JavaScriptImport#FullPathFileNames()} */
public final ReadOnlyList<String> fullPathFileNames;
// ********************************************************************************************
// ********************************************************************************************
// interface AnnotationMirror
// ********************************************************************************************
// ********************************************************************************************
// Stores the actual text of the @StaticFunctional annotation which was placed.
// This is nothing more than the exact line that was originally inserted into the class.
// The only reason this is even needed (in case you are wondering) is because the error
// checking & error printing code outputs this text when printing an error message.
private final String annotationAsStr;
/** {@inheritDoc} */ @Override
public String getAnnotationAsString() { return annotationAsStr; }
/** {@inheritDoc} */ @Override
public String getAnnotationName() { return "JavaScriptImport"; }
// ********************************************************************************************
// ********************************************************************************************
// Package-Private Constructor, Invoked by class "TypeAnnotationMirrors"
// ********************************************************************************************
// ********************************************************************************************
JSIMirror(
final List<? extends ExpressionTree> arguments,
final String annotationAsStr
)
{
this.annotationAsStr = annotationAsStr;
ReadOnlyList<String> fileNames = null;
ReadOnlyList<String> fullPathFileNames = null;
if (arguments.size() == 0)
{
this.fileNames = ReadOnlyArrayList.emptyROAL();;
this.fullPathFileNames = ReadOnlyArrayList.emptyROAL();
return;
}
for (ExpressionTree argument : arguments)
{
/*
System.out.println(
"argument: " + argument.toString() + '\n' +
"argument.getKind(): " + argument.getKind().toString() + '\n' +
"argument.getClass().getSimpleName(): " + argument.getClass().getSimpleName()
);
*/
// System.out.println(argument);
if (! (argument instanceof AssignmentTree)) Messager.assertFail(
"Annotation Placed:\n" +
" " + BCYAN + annotationAsStr + RESET + '\n' +
"While parsing the Arguments / Elements of an JSIMirror Annotation, the " +
"Oracle-Parser (com.sun.source.tree) returned an instance of `ExpressionTree` " +
"that was not an instance of `AssignmentTree`.\n" +
"ExpressionTree.toString(): " + argument.toString() + '\n' +
"All Annotation Expressions: " + StrCSV.toCSV(arguments, true, true, null) + '\n' +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.JSIMirror
);
String elemName = ((AssignmentTree) argument).getVariable().toString();
ExpressionTree elemValue = ((AssignmentTree) argument).getExpression();
/*
System.out.println(
" elemName: " + elemName + '\n' +
" elemValue.toString(): " + elemValue.toString() + '\n' +
" elemValue.getKind(): " + elemValue.getKind().toString() + '\n' +
" elemValue.getClass(): " + elemValue.getClass().getSimpleName() + '\n'
);
*/
if (elemName.equals("FileNames"))
{
if (fileNames != null) throw Messager.assertFail(
"Annotation Placed:\n" +
" " + BCYAN + annotationAsStr + RESET + '\n' +
"There are apparently multiple instances of the Annotation-Element " +
"'FileNames' included with the @CSSLinks Annotation\n" +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.JSIMirror
);
fileNames =
HELPER.handleStringArray(elemValue, "FileNames", JDUAnnotations.JSIMirror);
}
else if (elemName.equals("FullPathFileNames"))
{
if (fullPathFileNames != null) throw Messager.assertFail(
"Annotation Placed:\n" +
" " + BCYAN + annotationAsStr + RESET + '\n' +
"There are apparently multiple instances of the Annotation-Element " +
"'FullPathFileNames' included with the @CSSLinks Annotation\n" +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.JSIMirror
);
fullPathFileNames = HELPER.handleStringArray
(elemValue, "FullPathFileNames", JDUAnnotations.JSIMirror);
}
else throw Messager.assertFail(
"Annotation Placed:\n" +
" " + BCYAN + annotationAsStr + RESET + '\n' +
"There was an Expression Variable-Name that was neither 'FileNames' nor " +
"'FullPathFileNames', but rather: " + elemName + '\n' +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.JSIMirror
);
}
this.fileNames = fileNames;
this.fullPathFileNames = fullPathFileNames;
if (MsgVerbose.isVerbose()) MsgVerbose.println(
"@JavaScriptImport Annotation-Processing Mirror Class:" +
" FileNames: " + StrCSV.toCSV(this.fileNames, true, false, null) + '\n' +
" FullPathFileNames: " + StrCSV.toCSV(this.fullPathFileNames, true, false, null)
);
}
// ********************************************************************************************
// ********************************************************************************************
// toString
// ********************************************************************************************
// ********************************************************************************************
/** {@inheritDoc} */ @Override
public String toString()
{
return "This annotation isn't fully functioning yet. soon, but not right now.";
}
}
|