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 ThemisAnalysisClass
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 List<ThemisAnalysisReference> theAncestors;
46
47
48
49
50 private final Deque<ThemisAnalysisElement> theContents;
51
52
53
54
55 private final ThemisAnalysisDataMap theDataMap;
56
57
58
59
60 private final int theNumLines;
61
62
63
64
65 private ThemisAnalysisProperties theProperties;
66
67
68
69
70
71
72
73
74 ThemisAnalysisClass(final ThemisAnalysisParser pParser,
75 final ThemisAnalysisLine pLine) throws OceanusException {
76
77 theShortName = pLine.stripNextToken();
78 theProperties = pLine.getProperties();
79 final ThemisAnalysisContainer myParent = pParser.getParent();
80 final ThemisAnalysisDataMap myParentDataMap = myParent.getDataMap();
81 theDataMap = new ThemisAnalysisDataMap(myParentDataMap);
82
83
84 if (!(myParent instanceof ThemisAnalysisObject)
85 && (!(myParent instanceof ThemisAnalysisFile))) {
86 final int myId = myParentDataMap.getLocalId(theShortName);
87 theFullName = myParent.determineFullChildName(myId + theShortName);
88
89
90 } else {
91 theFullName = myParent.determineFullChildName(theShortName);
92 }
93
94
95 ThemisAnalysisLine myLine = pLine;
96 if (ThemisAnalysisGeneric.isGeneric(pLine)) {
97
98 theProperties = theProperties.setGenericVariables(new ThemisAnalysisGenericBase(pParser, myLine));
99 myLine = (ThemisAnalysisLine) pParser.popNextLine();
100 }
101
102
103 theDataMap.declareObject(this);
104
105
106 final Deque<ThemisAnalysisElement> myHeaders = ThemisAnalysisBuilder.parseHeaders(pParser, myLine);
107 theNumLines = myHeaders.size() + 1;
108
109
110 final Deque<ThemisAnalysisElement> myLines = ThemisAnalysisBuilder.processBody(pParser);
111
112
113 theContents = new ArrayDeque<>();
114 final ThemisAnalysisParser myParser = new ThemisAnalysisParser(myLines, theContents, this);
115
116
117 theProperties.resolveGeneric(myParser);
118
119
120 theAncestors = myParser.parseAncestors(myHeaders);
121 myParser.processLines();
122 }
123
124 @Override
125 public String getShortName() {
126 return theShortName;
127 }
128
129 @Override
130 public String getFullName() {
131 return theFullName;
132 }
133
134 @Override
135 public ThemisAnalysisDataMap getDataMap() {
136 return theDataMap;
137 }
138
139 @Override
140 public ThemisAnalysisProperties getProperties() {
141 return theProperties;
142 }
143
144 @Override
145 public Deque<ThemisAnalysisElement> getContents() {
146 return theContents;
147 }
148
149 @Override
150 public ThemisAnalysisContainer getParent() {
151 return this;
152 }
153
154 @Override
155 public List<ThemisAnalysisReference> getAncestors() {
156 return theAncestors;
157 }
158
159 @Override
160 public int getNumLines() {
161 return theNumLines;
162 }
163
164 @Override
165 public String toString() {
166 return getShortName();
167 }
168 }