Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/declarationbuilder.cpp
Show First 20 Lines • Show All 1235 Lines • ▼ Show 20 Line(s) | |||||
1236 | { | 1236 | { | ||
1237 | QualifiedIdentifier id; | 1237 | QualifiedIdentifier id; | ||
1238 | if (!m_isInternalFunctions) { | 1238 | if (!m_isInternalFunctions) { | ||
1239 | FunctionType::Ptr oldFunction = m_currentFunctionType; | 1239 | FunctionType::Ptr oldFunction = m_currentFunctionType; | ||
1240 | 1240 | | |||
1241 | DeclarationPointer dec; | 1241 | DeclarationPointer dec; | ||
1242 | if ( node->stringFunctionName ) { | 1242 | if ( node->stringFunctionName ) { | ||
1243 | dec = findDeclarationImport(FunctionDeclarationType, node->stringFunctionName); | 1243 | dec = findDeclarationImport(FunctionDeclarationType, node->stringFunctionName); | ||
1244 | | ||||
1245 | if (!dec) { | ||||
1246 | dec = findDeclarationImport(FunctionDeclarationType, node->stringFunctionName, GlobalScope); | ||||
1247 | } | ||||
1244 | } else if ( node->stringFunctionNameOrClass ) { | 1248 | } else if ( node->stringFunctionNameOrClass ) { | ||
1245 | id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | 1249 | id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | ||
1246 | dec = findDeclarationImport(FunctionDeclarationType, id); | 1250 | dec = findDeclarationImport(FunctionDeclarationType, id); | ||
1251 | | ||||
1252 | if (!dec) { | ||||
1253 | id.setExplicitlyGlobal(true); | ||||
1254 | dec = findDeclarationImport(FunctionDeclarationType, id); | ||||
1255 | } | ||||
1247 | } else { | 1256 | } else { | ||
1248 | ///TODO: node->varFunctionName | 1257 | ///TODO: node->varFunctionName | ||
1249 | } | 1258 | } | ||
1250 | 1259 | | |||
1251 | if ( dec ) { | 1260 | if ( dec ) { | ||
1252 | m_currentFunctionType = dec->type<FunctionType>(); | 1261 | m_currentFunctionType = dec->type<FunctionType>(); | ||
1253 | } else { | 1262 | } else { | ||
1254 | m_currentFunctionType = nullptr; | 1263 | m_currentFunctionType = nullptr; | ||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Line(s) | 1541 | reportError(i18n("The use statement with non-compound name '%1' has no effect.", | |||
1534 | node->identifier, IProblem::Warning); | 1543 | node->identifier, IProblem::Warning); | ||
1535 | return; | 1544 | return; | ||
1536 | } | 1545 | } | ||
1537 | IdentifierAst* idNode = node->aliasIdentifier ? node->aliasIdentifier : node->identifier->namespaceNameSequence->back()->element; | 1546 | IdentifierAst* idNode = node->aliasIdentifier ? node->aliasIdentifier : node->identifier->namespaceNameSequence->back()->element; | ||
1538 | IdentifierPair id = identifierPairForNode(idNode); | 1547 | IdentifierPair id = identifierPairForNode(idNode); | ||
1539 | 1548 | | |||
1540 | ///TODO: case insensitive! | 1549 | ///TODO: case insensitive! | ||
1541 | QualifiedIdentifier qid = identifierForNamespace(node->identifier, m_editor); | 1550 | QualifiedIdentifier qid = identifierForNamespace(node->identifier, m_editor); | ||
1542 | ///TODO: find out why this must be done (see mail to kdevelop-devel on jan 18th 2011) | | |||
1543 | qid.setExplicitlyGlobal( false ); | | |||
1544 | 1551 | | |||
1545 | DeclarationPointer dec = findDeclarationImport(ClassDeclarationType, qid); | 1552 | DeclarationPointer dec = findDeclarationImport(ClassDeclarationType, qid); | ||
1546 | 1553 | | |||
1554 | if (!dec && !qid.explicitlyGlobal()) { | ||||
1555 | QualifiedIdentifier globalQid = qid; | ||||
1556 | globalQid.setExplicitlyGlobal(true); | ||||
1557 | dec = findDeclarationImport(ClassDeclarationType, globalQid); | ||||
1558 | } | ||||
1559 | | ||||
1547 | if (dec) | 1560 | if (dec) | ||
1548 | { | 1561 | { | ||
1549 | // Check for a name conflict | 1562 | // Check for a name conflict | ||
1550 | DeclarationPointer dec2 = findDeclarationImport(ClassDeclarationType, id.second); | 1563 | DeclarationPointer dec2 = findDeclarationImport(ClassDeclarationType, id.second); | ||
1551 | 1564 | | |||
1552 | if (dec2 && dec2->context()->scopeIdentifier() == currentContext()->scopeIdentifier() && | 1565 | if (dec2 && dec2->context()->scopeIdentifier() == currentContext()->scopeIdentifier() && | ||
1553 | dec2->context()->topContext() == currentContext()->topContext() && | 1566 | dec2->context()->topContext() == currentContext()->topContext() && | ||
1554 | dec2->identifier().toString() == id.second.toString()) | 1567 | dec2->identifier().toString() == id.second.toString()) | ||
1555 | { | 1568 | { | ||
1556 | reportError(i18n("Cannot use '%1' as '%2' because the name is already in use.", | 1569 | reportError(i18n("Cannot use '%1' as '%2' because the name is already in use.", | ||
1557 | dec.data()->identifier().toString(), id.second.toString()), | 1570 | dec.data()->identifier().toString(), id.second.toString()), | ||
1558 | node->identifier, IProblem::Error); | 1571 | node->identifier, IProblem::Error); | ||
1559 | return; | 1572 | return; | ||
1560 | } | 1573 | } | ||
1561 | 1574 | | |||
1562 | AliasDeclaration* decl = openDefinition<AliasDeclaration>(id.second, m_editor->findRange(idNode)); | 1575 | AliasDeclaration* decl = openDefinition<AliasDeclaration>(id.second, m_editor->findRange(idNode)); | ||
1563 | decl->setAliasedDeclaration(dec.data()); | 1576 | decl->setAliasedDeclaration(dec.data()); | ||
1564 | } | 1577 | } | ||
1565 | else | 1578 | else | ||
1566 | { | 1579 | { | ||
1580 | // NamespaceAliasDeclarations can't use a global import identifier | ||||
1581 | qid.setExplicitlyGlobal(false); | ||||
1582 | | ||||
1567 | NamespaceAliasDeclaration* decl = openDefinition<NamespaceAliasDeclaration>(id.second, | 1583 | NamespaceAliasDeclaration* decl = openDefinition<NamespaceAliasDeclaration>(id.second, | ||
1568 | m_editor->findRange(idNode)); | 1584 | m_editor->findRange(idNode)); | ||
1569 | decl->setImportIdentifier( qid ); | 1585 | decl->setImportIdentifier( qid ); | ||
1570 | decl->setPrettyName( id.first ); | 1586 | decl->setPrettyName( id.first ); | ||
1571 | decl->setKind(Declaration::NamespaceAlias); | 1587 | decl->setKind(Declaration::NamespaceAlias); | ||
1572 | } | 1588 | } | ||
1573 | closeDeclaration(); | 1589 | closeDeclaration(); | ||
1574 | 1590 | | |||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |