Changeset View
Changeset View
Standalone View
Standalone View
language/duchain/identifier.h
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 97 | public: | |||
---|---|---|---|---|---|
121 | { | 121 | { | ||
122 | return index; | 122 | return index; | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | private: | 125 | private: | ||
126 | uint index; | 126 | uint index; | ||
127 | }; | 127 | }; | ||
128 | 128 | | |||
129 | /** | 129 | /** | ||
kfunk: Please document enum + enum values | |||||
Thinking about it. This needs a NoOptions = 0x0 enumerator (i.e. for saying IgnoreExplicitlyGlobal = false & AddTemplateIdentifiers = false). The other enumerator values need to be bumped. kfunk: Thinking about it. This needs a `NoOptions = 0x0` enumerator (i.e. for saying… | |||||
130 | * Flags to control the string representation of identifiers. | ||||
131 | */ | ||||
132 | enum IdentifierStringFormattingOption { | ||||
133 | NoOptions = 0x0, | ||||
134 | | ||||
135 | /// Removes explicit global prefix from the result. | ||||
136 | /// When enabled, global identifiers will be formatted as "globalIdentifierFormattedString" | ||||
137 | /// instead "::globalIdentifierFormattedString". | ||||
138 | RemoveExplicitlyGlobalPrefix = 0x1, | ||||
139 | | ||||
140 | /// Removes template information from the result. | ||||
141 | /// When enabled, TemplateClass< someDataType > will be formatted as plain "TemplateClass". | ||||
142 | RemoveTemplateInformation = 0x2 | ||||
143 | }; | ||||
144 | Q_DECLARE_FLAGS(IdentifierStringFormattingOptions, IdentifierStringFormattingOption) | ||||
145 | | ||||
146 | /** | ||||
130 | * Represents a single unqualified identifier | 147 | * Represents a single unqualified identifier | ||
131 | */ | 148 | */ | ||
132 | class KDEVPLATFORMLANGUAGE_EXPORT Identifier | 149 | class KDEVPLATFORMLANGUAGE_EXPORT Identifier | ||
133 | { | 150 | { | ||
134 | friend class QualifiedIdentifier; | 151 | friend class QualifiedIdentifier; | ||
135 | 152 | | |||
136 | public: | 153 | public: | ||
137 | /** | 154 | /** | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
186 | * @warning This is expensive. | 203 | * @warning This is expensive. | ||
187 | */ | 204 | */ | ||
188 | IndexedTypeIdentifier templateIdentifier(int num) const; | 205 | IndexedTypeIdentifier templateIdentifier(int num) const; | ||
189 | uint templateIdentifiersCount() const; | 206 | uint templateIdentifiersCount() const; | ||
190 | void appendTemplateIdentifier(const IndexedTypeIdentifier& identifier); | 207 | void appendTemplateIdentifier(const IndexedTypeIdentifier& identifier); | ||
191 | void clearTemplateIdentifiers(); | 208 | void clearTemplateIdentifiers(); | ||
192 | void setTemplateIdentifiers(const QList<IndexedTypeIdentifier>& templateIdentifiers); | 209 | void setTemplateIdentifiers(const QList<IndexedTypeIdentifier>& templateIdentifiers); | ||
193 | 210 | | |||
194 | QString toString() const; | 211 | QString toString(IdentifierStringFormattingOptions options = NoOptions) const; | ||
Better add an enum for the string formatting options, e.g.: enum StringFormattingOption { AddTemplateIdentifiers = 0, IgnoreExplicitelyGlobal = 1 << 0 }; Q_DECLARE_FLAGS(StringFormattingOptions StringFormattingOption) // ... QString toString(StringFormattingOptions options) Note: We have to push this patch to master, since it's an ABI incompatible change. OR (if we want to have it in 5.0, which makes sense) create extra methods which have the additional parameter, keep the original method signatures untouched. kfunk: Better add an enum for the string formatting options, e.g.:
```
enum StringFormattingOption {… | |||||
195 | 212 | | |||
196 | bool operator==(const Identifier& rhs) const; | 213 | bool operator==(const Identifier& rhs) const; | ||
197 | bool operator!=(const Identifier& rhs) const; | 214 | bool operator!=(const Identifier& rhs) const; | ||
198 | 215 | | |||
199 | bool isEmpty() const; | 216 | bool isEmpty() const; | ||
200 | 217 | | |||
201 | /** | 218 | /** | ||
202 | * @return a unique index within the global identifier repository for this identifier. | 219 | * @return a unique index within the global identifier repository for this identifier. | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 245 | public: | |||
292 | bool isExpression() const; | 309 | bool isExpression() const; | ||
293 | /** | 310 | /** | ||
294 | * Set the expression-flag, that can be retrieved by isExpression(). | 311 | * Set the expression-flag, that can be retrieved by isExpression(). | ||
295 | * This flag is not respected while creating the hash-value and while operator==() comparison. | 312 | * This flag is not respected while creating the hash-value and while operator==() comparison. | ||
296 | * It is respected while isSame(..) comparison. | 313 | * It is respected while isSame(..) comparison. | ||
297 | */ | 314 | */ | ||
298 | void setIsExpression(bool); | 315 | void setIsExpression(bool); | ||
299 | 316 | | |||
300 | QString toString(bool ignoreExplicitlyGlobal = false) const; | 317 | QString toString(IdentifierStringFormattingOptions options = NoOptions) const; | ||
301 | QStringList toStringList() const; | 318 | QStringList toStringList(IdentifierStringFormattingOptions options = NoOptions) const; | ||
302 | 319 | | |||
303 | QualifiedIdentifier operator+(const QualifiedIdentifier& rhs) const; | 320 | QualifiedIdentifier operator+(const QualifiedIdentifier& rhs) const; | ||
304 | QualifiedIdentifier& operator+=(const QualifiedIdentifier& rhs); | 321 | QualifiedIdentifier& operator+=(const QualifiedIdentifier& rhs); | ||
305 | 322 | | |||
306 | /** | 323 | /** | ||
307 | * Nicer interfaces to merge | 324 | * Nicer interfaces to merge | ||
308 | */ | 325 | */ | ||
309 | QualifiedIdentifier operator+(const Identifier& rhs) const; | 326 | QualifiedIdentifier operator+(const Identifier& rhs) const; | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 381 | public: | |||
398 | void setPointerDepth(int); | 415 | void setPointerDepth(int); | ||
399 | 416 | | |||
400 | /** | 417 | /** | ||
401 | * Whether the target of pointer 'depthNumber' is constant | 418 | * Whether the target of pointer 'depthNumber' is constant | ||
402 | */ | 419 | */ | ||
403 | bool isConstPointer(int depthNumber) const; | 420 | bool isConstPointer(int depthNumber) const; | ||
404 | void setIsConstPointer(int depthNumber, bool constant); | 421 | void setIsConstPointer(int depthNumber, bool constant); | ||
405 | 422 | | |||
406 | QString toString(bool ignoreExplicitlyGlobal = false) const; | 423 | QString toString(IdentifierStringFormattingOptions options = NoOptions) const; | ||
407 | 424 | | |||
408 | uint hash() const; | 425 | uint hash() const; | ||
409 | 426 | | |||
410 | /** | 427 | /** | ||
411 | * The comparison-operators do not respect explicitlyGlobal and isExpression, they only respect the real scope. | 428 | * The comparison-operators do not respect explicitlyGlobal and isExpression, they only respect the real scope. | ||
412 | * This is for convenient use in hash-tables etc. | 429 | * This is for convenient use in hash-tables etc. | ||
413 | */ | 430 | */ | ||
414 | bool operator==(const IndexedTypeIdentifier& rhs) const; | 431 | bool operator==(const IndexedTypeIdentifier& rhs) const; | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
Please document enum + enum values