1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.lethe.analysis;
18
19 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
20 import io.github.tonywasher.joceanus.themis.lethe.analysis.ThemisAnalysisFile.ThemisAnalysisObject;
21 import io.github.tonywasher.joceanus.themis.lethe.analysis.ThemisAnalysisGeneric.ThemisAnalysisGenericBase;
22
23 import java.util.ArrayDeque;
24 import java.util.Deque;
25 import java.util.List;
26
27
28
29
30 public class ThemisAnalysisInterface
31 implements ThemisAnalysisObject {
32
33
34
35 private final String theShortName;
36
37
38
39
40 private final String theFullName;
41
42
43
44
45 private final boolean isAnnotation;
46
47
48
49
50 private final List<ThemisAnalysisReference> theAncestors;
51
52
53
54
55 private final Deque<ThemisAnalysisElement> theContents;
56
57
58
59
60 private final ThemisAnalysisDataMap theDataMap;
61
62
63
64
65 private final int theNumLines;
66
67
68
69
70 private ThemisAnalysisProperties theProperties;
71
72
73
74
75
76
77
78
79
80 ThemisAnalysisInterface(final ThemisAnalysisParser pParser,
81 final boolean pAnnotation,
82 final ThemisAnalysisLine pLine) throws OceanusException {
83
84 theShortName = pLine.stripNextToken();
85 theProperties = pLine.getProperties();
86 isAnnotation = pAnnotation;
87 final ThemisAnalysisContainer myParent = pParser.getParent();
88 final ThemisAnalysisDataMap myParentDataMap = myParent.getDataMap();
89 theDataMap = new ThemisAnalysisDataMap(myParentDataMap);
90
91
92 if (!(myParent instanceof ThemisAnalysisObject)
93 && (!(myParent instanceof ThemisAnalysisFile))) {
94 final int myId = myParentDataMap.getLocalId(theShortName);
95 theFullName = myParent.determineFullChildName(myId + theShortName);
96
97
98 } else {
99 theFullName = myParent.determineFullChildName(theShortName);
100 }
101
102
103 ThemisAnalysisLine myLine = pLine;
104 if (ThemisAnalysisGeneric.isGeneric(pLine)) {
105
106 theProperties = theProperties.setGenericVariables(new ThemisAnalysisGenericBase(pParser, myLine));
107 myLine = (ThemisAnalysisLine) pParser.popNextLine();
108 }
109
110
111 theDataMap.declareObject(this);
112
113
114 final Deque<ThemisAnalysisElement> myHeaders = ThemisAnalysisBuilder.parseHeaders(pParser, myLine);
115 theNumLines = myHeaders.size() + 1;
116
117
118 final Deque<ThemisAnalysisElement> myLines = ThemisAnalysisBuilder.processBody(pParser);
119
120
121 theContents = new ArrayDeque<>();
122 final ThemisAnalysisParser myParser = new ThemisAnalysisParser(myLines, theContents, this);
123
124
125 theProperties.resolveGeneric(myParser);
126
127
128 theAncestors = myParser.parseAncestors(myHeaders);
129 myParser.processLines();
130 }
131
132
133
134
135
136
137 public boolean isAnnotation() {
138 return isAnnotation;
139 }
140
141 @Override
142 public String getShortName() {
143 return theShortName;
144 }
145
146 @Override
147 public String getFullName() {
148 return theFullName;
149 }
150
151 @Override
152 public ThemisAnalysisDataMap getDataMap() {
153 return theDataMap;
154 }
155
156 @Override
157 public ThemisAnalysisProperties getProperties() {
158 return theProperties;
159 }
160
161 @Override
162 public Deque<ThemisAnalysisElement> getContents() {
163 return theContents;
164 }
165
166 @Override
167 public ThemisAnalysisContainer getParent() {
168 return this;
169 }
170
171 @Override
172 public List<ThemisAnalysisReference> getAncestors() {
173 return theAncestors;
174 }
175
176 @Override
177 public int getNumLines() {
178 return theNumLines;
179 }
180
181 @Override
182 public String toString() {
183 return getShortName();
184 }
185 }