Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/usebuilder.cpp
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Line(s) | 221 | foreach ( Declaration* dec, currentContext()->topContext()->findDeclarations(identifier) ) { | |||
---|---|---|---|---|---|
222 | if ( dec->kind() == Declaration::Import ) { | 222 | if ( dec->kind() == Declaration::Import ) { | ||
223 | newUse(node->includeExpression, DeclarationPointer(dec)); | 223 | newUse(node->includeExpression, DeclarationPointer(dec)); | ||
224 | return; | 224 | return; | ||
225 | } | 225 | } | ||
226 | } | 226 | } | ||
227 | } | 227 | } | ||
228 | } | 228 | } | ||
229 | 229 | | |||
230 | void UseBuilder::visitUseStatement(UseStatementAst* node) | ||||
231 | { | ||||
232 | if ( node->useFunction != -1 ) | ||||
233 | { | ||||
234 | m_useNamespaceType = FunctionDeclarationType; | ||||
235 | } | ||||
236 | else if ( node->useConst != -1 ) | ||||
237 | { | ||||
238 | m_useNamespaceType = ConstantDeclarationType; | ||||
239 | } | ||||
240 | else | ||||
241 | { | ||||
242 | m_useNamespaceType = NamespaceDeclarationType; | ||||
243 | } | ||||
244 | UseBuilderBase::visitUseStatement(node); | ||||
245 | } | ||||
246 | | ||||
230 | void UseBuilder::visitUseNamespace(UseNamespaceAst* node) | 247 | void UseBuilder::visitUseNamespace(UseNamespaceAst* node) | ||
231 | { | 248 | { | ||
232 | buildNamespaceUses(node->identifier, NamespaceDeclarationType); | 249 | buildNamespaceUses(node->identifier, m_useNamespaceType); | ||
233 | } | 250 | } | ||
234 | 251 | | |||
235 | void UseBuilder::buildNamespaceUses(NamespacedIdentifierAst* node, DeclarationType lastType) | 252 | void UseBuilder::buildNamespaceUses(NamespacedIdentifierAst* node, DeclarationType lastType) | ||
236 | { | 253 | { | ||
237 | QualifiedIdentifier identifier = identifierForNamespace(node, m_editor); | 254 | QualifiedIdentifier identifier = identifierForNamespace(node, m_editor, lastType == ConstantDeclarationType); | ||
238 | 255 | | |||
239 | QualifiedIdentifier curId; | 256 | QualifiedIdentifier curId; | ||
240 | 257 | | |||
241 | // check if we need to resolve the namespaced identifier globally or locally | 258 | // check if we need to resolve the namespaced identifier globally or locally | ||
242 | DeclarationPointer tempDec = findDeclarationImport(ClassDeclarationType, identifier); | 259 | DeclarationPointer tempDec = findDeclarationImport(lastType, identifier); | ||
243 | 260 | | |||
244 | // if we couldn't find a class declaration, it might be a partial namespace identifier | 261 | // if we couldn't find a class declaration, it might be a partial namespace identifier | ||
245 | if (!tempDec) { | 262 | if (!tempDec) { | ||
246 | tempDec = findDeclarationImport(NamespaceDeclarationType, identifier); | 263 | tempDec = findDeclarationImport(NamespaceDeclarationType, identifier); | ||
247 | } | 264 | } | ||
248 | 265 | | |||
249 | if (!tempDec && !identifier.explicitlyGlobal()) { | 266 | if (!tempDec && !identifier.explicitlyGlobal()) { | ||
250 | identifier.setExplicitlyGlobal(true); | 267 | identifier.setExplicitlyGlobal(true); | ||
251 | tempDec = findDeclarationImport(ClassDeclarationType, identifier); | 268 | tempDec = findDeclarationImport(lastType, identifier); | ||
252 | 269 | | |||
253 | if (!tempDec) { | 270 | if (!tempDec) { | ||
254 | tempDec = findDeclarationImport(NamespaceDeclarationType, identifier); | 271 | tempDec = findDeclarationImport(NamespaceDeclarationType, identifier); | ||
255 | } | 272 | } | ||
256 | 273 | | |||
257 | // Can't resolve either globally or locally, so revert back to original | 274 | // Can't resolve either globally or locally, so revert back to original | ||
258 | if (!tempDec) { | 275 | if (!tempDec) { | ||
259 | identifier.setExplicitlyGlobal(false); | 276 | identifier.setExplicitlyGlobal(false); | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |