|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#ifndef _HANODEITERATOR_H_
|
|
|
20 |
#define _HANODEITERATOR_H_
|
|
|
21 |
|
|
|
22 |
#include "CmdGlobals.h"
|
|
|
23 |
#ifdef __WIN__
|
|
|
24 |
#pragma warning(disable:4786)
|
|
|
25 |
#endif
|
|
|
26 |
|
|
|
27 |
#include <assert.h>
|
|
|
28 |
#include <map>
|
|
|
29 |
#include <list>
|
|
|
30 |
#include <xercesc/dom/DOM.hpp>
|
|
|
31 |
|
|
|
32 |
#include "ReportGenerator.h"
|
|
|
33 |
#include "Issues.h"
|
|
|
34 |
#include "NodeIndex.h"
|
|
|
35 |
|
|
|
36 |
using namespace std;
|
|
|
37 |
|
|
|
38 |
XERCES_CPP_NAMESPACE_USE
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* The BBCAnalyser utilizes the HANodeIterator for easy access to a GCCXML
|
|
|
43 |
* generated XML document. The HANodeIterator provides methods for an
|
|
|
44 |
* indexed access to the XML nodes with a node ID and a fully qualified
|
|
|
45 |
* name. The issues are also reported through the HANodeIterator
|
|
|
46 |
*/
|
|
|
47 |
class HANodeIterator
|
|
|
48 |
{
|
|
|
49 |
public:
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Constructor
|
|
|
53 |
* @param aRootnode root DOM node
|
|
|
54 |
* @param aNodemap referencce to NodeIndex
|
|
|
55 |
* @param aReport reference to ReportGenerator
|
|
|
56 |
* @param aFilesToAnalyse list of files to analyse
|
|
|
57 |
* @param aBaselineNode true if currently handling baseline node
|
|
|
58 |
*/
|
|
|
59 |
HANodeIterator(DOMNode * aRootnode, NodeIndex & aNodemap, ReportGenerator & aReport,
|
|
|
60 |
const list< pair<string,string> >& aFilesToAnalyse, bool aBaselineNode );
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Returns node
|
|
|
64 |
* @return pointer to DOMNode
|
|
|
65 |
*/
|
|
|
66 |
DOMNode* operator->() const;
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Finds node from the XML tree by the attribute "id"
|
|
|
70 |
* @param nodeId ID of the searchable node
|
|
|
71 |
* @return true if the node is found
|
|
|
72 |
*/
|
|
|
73 |
bool FindNodeById(const XMLCh * nodeId);
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Finds node from the XML tree by the fully qualified name (C++) of it
|
|
|
77 |
* @param nodeName name the searchable node
|
|
|
78 |
* @return true if the node is found
|
|
|
79 |
*/
|
|
|
80 |
bool FindNodeByName(pair<const XMLCh *,const XMLCh *> nodeName);
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* Gets the fully qualified name of this node
|
|
|
84 |
* @return fully qualified name of the node
|
|
|
85 |
*/
|
|
|
86 |
pair<const XMLCh *,const XMLCh *> GetFullyQualifiedName();
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* Adds this node in the index
|
|
|
90 |
*/
|
|
|
91 |
void IndexNode();
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* Adds this file node to the file index
|
|
|
95 |
* @param filetoanalyse file to be anylysed
|
|
|
96 |
*/
|
|
|
97 |
void IndexFileNode(bool filetoanalyse);
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* Generates fully qualified name for this node and adds it to index
|
|
|
101 |
* if parameter index is true
|
|
|
102 |
* @param index when this is true the node is added to index
|
|
|
103 |
*/
|
|
|
104 |
void NameNode(bool index = false);
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Gets the attribute of this node
|
|
|
108 |
* @param attribute attribute to get
|
|
|
109 |
* @return attribute value or NULL
|
|
|
110 |
*/
|
|
|
111 |
const XMLCh* GetAttribute(const char* attribute) const;
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* Gets the attribute of this node
|
|
|
115 |
* @param attribute attribute to get
|
|
|
116 |
* @return attribute value or NULL
|
|
|
117 |
*/
|
|
|
118 |
const XMLCh* GetAttribute(const XMLCh* attribute) const;
|
|
|
119 |
|
|
|
120 |
/**
|
|
|
121 |
* Checks if the attribute that can have values 0 or 1 has value 1 (true)
|
|
|
122 |
* or 0 (false). If the attribute is missing return false.
|
|
|
123 |
*
|
|
|
124 |
* @param attribute attribute to search for
|
|
|
125 |
* @return true if attribute is found
|
|
|
126 |
*/
|
|
|
127 |
bool CheckForBooleanAttribute(const XMLCh* attribute) const;
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Checks if the attribute that can have values 0 or 1 has value 1 (true)
|
|
|
131 |
* or 0 (false). If the attribute is missing return false.
|
|
|
132 |
*
|
|
|
133 |
* @param attribute attribute to search for
|
|
|
134 |
* @return true if attribute is found
|
|
|
135 |
*/
|
|
|
136 |
bool CheckForBooleanAttribute(const char* attribute) const;
|
|
|
137 |
|
|
|
138 |
/**
|
|
|
139 |
* Set value to this node
|
|
|
140 |
*
|
|
|
141 |
* @param attribute attribute to set
|
|
|
142 |
* @param value attribute value to set
|
|
|
143 |
*/
|
|
|
144 |
void SetAttribute(const char* attribute, const char* value);
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
* Set value to this node
|
|
|
148 |
*
|
|
|
149 |
* @param attribute attribute to set
|
|
|
150 |
* @param value attribute value to set
|
|
|
151 |
*/
|
|
|
152 |
void SetAttribute(const XMLCh* attribute, const XMLCh* value);
|
|
|
153 |
|
|
|
154 |
/**
|
|
|
155 |
* Set value to this node
|
|
|
156 |
*
|
|
|
157 |
* @param attribute attribute to set
|
|
|
158 |
* @param value attribute value to set
|
|
|
159 |
*/
|
|
|
160 |
void SetAttribute(const char* attribute, const XMLCh* value);
|
|
|
161 |
|
|
|
162 |
/**
|
|
|
163 |
* Set value to this node
|
|
|
164 |
*
|
|
|
165 |
* @param attribute attribute to set
|
|
|
166 |
* @param value attribute value to set
|
|
|
167 |
*/
|
|
|
168 |
void SetAttribute(const XMLCh* attribute, const char* value);
|
|
|
169 |
|
|
|
170 |
/**
|
|
|
171 |
* Get elements by tagname
|
|
|
172 |
* @param tag tagname
|
|
|
173 |
* @return pointer to DOMNodeList
|
|
|
174 |
*/
|
|
|
175 |
DOMNodeList* GetElementsByTagName(const char* tag) const;
|
|
|
176 |
|
|
|
177 |
/**
|
|
|
178 |
* Get elements by tagname
|
|
|
179 |
* @param tag tagname
|
|
|
180 |
* @return pointer to DOMNodeList
|
|
|
181 |
*/
|
|
|
182 |
DOMNodeList* GetElementsByTagName(const XMLCh* tag) const;
|
|
|
183 |
|
|
|
184 |
/**
|
|
|
185 |
* Adds issue to the report. This node is marked as the cause for the issue
|
|
|
186 |
* @param aIdentityId identity= Class, ExportedFunction, Enumeration, etc.
|
|
|
187 |
* @param aTypeId what was happened ( something was removed, addded, changed..)
|
|
|
188 |
* @param bcseverity how severe the issue was for binary compatibility
|
|
|
189 |
* @param scseverity how severe the issue was for source compatibility
|
|
|
190 |
* @param ignoreinfo reason to ignore
|
|
|
191 |
* @param fileid ID of the file
|
|
|
192 |
* @param name filename
|
|
|
193 |
*/
|
|
|
194 |
void addIssue(TIssueIdentity aIdentityId, TIssueType aTypeId, TBCSeverity bcseverity, TSCSeverity scseverity, string ignoreinfo, const XMLCh* fileid, const string name, int lineNumber) const;
|
|
|
195 |
|
|
|
196 |
/**
|
|
|
197 |
* Check if this node is in the file that is currently analysed
|
|
|
198 |
* @return true if this node is in the file that is currently analysed
|
|
|
199 |
*/
|
|
|
200 |
bool toBeAnalysed();
|
|
|
201 |
|
|
|
202 |
/**
|
|
|
203 |
* Generates ignore information
|
|
|
204 |
* @param aIdentityId see above
|
|
|
205 |
* @param aTypeId see above
|
|
|
206 |
* @return ignore info as string
|
|
|
207 |
*/
|
|
|
208 |
string generateIgnoreInformation(const TIssueIdentity& aIdentityId, const TIssueType& aTypeId) const;
|
|
|
209 |
|
|
|
210 |
/**
|
|
|
211 |
* Generates ignore information
|
|
|
212 |
* @param other reference to other HANodeIterator object
|
|
|
213 |
* @return true if the same node type found
|
|
|
214 |
*/
|
|
|
215 |
bool IsSameNodeType(const HANodeIterator& other);
|
|
|
216 |
|
|
|
217 |
public:
|
|
|
218 |
//! Does not own
|
|
|
219 |
DOMNode *root;
|
|
|
220 |
|
|
|
221 |
//! Does not own
|
|
|
222 |
DOMNode *current;
|
|
|
223 |
|
|
|
224 |
//! Does not own
|
|
|
225 |
NodeIndex &iNodeIndex;
|
|
|
226 |
|
|
|
227 |
//! Reference to ReporGenerator object (Issue report)
|
|
|
228 |
ReportGenerator &iReport;
|
|
|
229 |
|
|
|
230 |
//! Does not own, files that is analysed
|
|
|
231 |
const list< pair<string,string> >& iFilesToAnalyse;
|
|
|
232 |
|
|
|
233 |
//! Is this baseline node?
|
|
|
234 |
bool iBaselineNode;
|
|
|
235 |
|
|
|
236 |
private:
|
|
|
237 |
};
|
|
|
238 |
|
|
|
239 |
// ---------------------------------------------------------------------------------------------
|
|
|
240 |
// A quick fix to disable compiler warnings about CheckAccessibility
|
|
|
241 |
|
|
|
242 |
/**
|
|
|
243 |
* Checks if the member memberNode is visible
|
|
|
244 |
* @param memberNode the node which accessibilty is determined
|
|
|
245 |
* @return true if accessible
|
|
|
246 |
*/
|
|
|
247 |
bool CheckAccessibility(HANodeIterator memberNode);
|
|
|
248 |
|
|
|
249 |
/**
|
|
|
250 |
* Checks if the member memberNode is visible and if the visibility is
|
|
|
251 |
* through inline function
|
|
|
252 |
* @param memberNode the node which accessibilty is determined
|
|
|
253 |
* @param exposedByInline true if node is exposed by inline
|
|
|
254 |
* @return true if accessible
|
|
|
255 |
*/
|
|
|
256 |
bool CheckAccessibility(HANodeIterator memberNode, bool & exposedByInline);
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
/**
|
|
|
260 |
* Checks to see if a member with access "access" is visible from class classNode
|
|
|
261 |
* through inline function
|
|
|
262 |
* @param classNode the node which accessibilty is determined
|
|
|
263 |
* @param exposedByInline true if node is exposed by inline
|
|
|
264 |
* @param access which kind of access this node has
|
|
|
265 |
* @return true if accessible
|
|
|
266 |
*/
|
|
|
267 |
bool CheckAccessibility(HANodeIterator classNode, bool & exposedByInline, TAccess access);
|
|
|
268 |
|
|
|
269 |
// ---------------------------------------------------------------------------------------------
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
template<TIssueIdentity Identity,TIssueType IssueType>
|
|
|
273 |
void AddIssue(const HANodeIterator* self, const HANodeIterator& ignorenode, int lineNumber, const XMLCh* fileid, const DataMember & data)
|
|
|
274 |
{
|
|
|
275 |
bool exposedByInline=false;
|
|
|
276 |
CheckAccessibility(*self,exposedByInline,data.iAccess);
|
|
|
277 |
|
|
|
278 |
TBCSeverity sev = BCseverityAccessible<Identity,IssueType>(!exposedByInline);
|
|
|
279 |
TSCSeverity scsev = SCseverityAccessible<Identity,IssueType>(!exposedByInline);
|
|
|
280 |
string ign = ignoreInfo<Identity,IssueType>(*self,ignorenode);
|
|
|
281 |
self->addIssue(Identity,IssueType,sev,scsev,ign,fileid, data.iName,lineNumber);
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
template<TIssueIdentity Identity,TIssueType IssueType>
|
|
|
285 |
void AddIssue(const HANodeIterator* self, const HANodeIterator& ignorenode, int lineNumber, const XMLCh* fileid=NULL, const string namepostfix="")
|
|
|
286 |
{
|
|
|
287 |
bool exposedByInline=false;
|
|
|
288 |
CheckAccessibility(*self,exposedByInline);
|
|
|
289 |
|
|
|
290 |
TBCSeverity sev = BCseverityAccessible<Identity,IssueType>(!exposedByInline);
|
|
|
291 |
TSCSeverity scsev = SCseverityAccessible<Identity,IssueType>(!exposedByInline);
|
|
|
292 |
string ign = ignoreInfo<Identity,IssueType>(*self,ignorenode);
|
|
|
293 |
self->addIssue(Identity,IssueType,sev,scsev,ign,fileid, namepostfix,lineNumber);
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
#endif
|