Changeset View
Changeset View
Standalone View
Standalone View
duchain/declarationbuilder.cpp
Show First 20 Lines • Show All 914 Lines • ▼ Show 20 Line(s) | 899 | items["addsTypeOfArgContent"] = [&]() { | |||
---|---|---|---|---|---|
915 | for ( auto sourceContainer : sources ) { | 915 | for ( auto sourceContainer : sources ) { | ||
916 | if ( ! sourceContainer->contentType() ) { | 916 | if ( ! sourceContainer->contentType() ) { | ||
917 | continue; | 917 | continue; | ||
918 | } | 918 | } | ||
919 | container->addContentType<Python::UnsureType>(sourceContainer->contentType().abstractType()); | 919 | container->addContentType<Python::UnsureType>(sourceContainer->contentType().abstractType()); | ||
920 | v.lastDeclaration()->setType(container); | 920 | v.lastDeclaration()->setType(container); | ||
921 | } | 921 | } | ||
922 | }; | 922 | }; | ||
923 | 923 | auto docstring = function->comment(); | |||
924 | foreach ( const QString& key, items.keys() ) { | 924 | if ( ! docstring.isEmpty() ) { | ||
925 | if ( Helper::docstringContainsHint(function.data(), key, &args) ) { | 925 | foreach ( const auto& key, items.keys() ) { | ||
926 | if ( Helper::docstringContainsHint(docstring, key, &args) ) { | ||||
926 | items[key](); | 927 | items[key](); | ||
927 | } | 928 | } | ||
928 | } | 929 | } | ||
929 | } | 930 | } | ||
931 | } | ||||
930 | 932 | | |||
931 | void DeclarationBuilder::addArgumentTypeHints(CallAst* node, DeclarationPointer function) | 933 | void DeclarationBuilder::addArgumentTypeHints(CallAst* node, DeclarationPointer function) | ||
932 | { | 934 | { | ||
933 | DUChainReadLocker lock; | 935 | DUChainReadLocker lock; | ||
934 | auto funcInfo = Helper::functionForCalled(function.data()); | 936 | auto funcInfo = Helper::functionForCalled(function.data()); | ||
935 | auto lastFunctionDeclaration = funcInfo.declaration; | 937 | auto lastFunctionDeclaration = funcInfo.declaration; | ||
936 | 938 | | |||
937 | if ( ! lastFunctionDeclaration ) { | 939 | if ( ! lastFunctionDeclaration ) { | ||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Line(s) | 1334 | { | |||
1340 | visitDecorators<ClassDeclaration>(node->decorators, dec); | 1342 | visitDecorators<ClassDeclaration>(node->decorators, dec); | ||
1341 | lock.lock(); | 1343 | lock.lock(); | ||
1342 | eventuallyAssignInternalContext(); | 1344 | eventuallyAssignInternalContext(); | ||
1343 | 1345 | | |||
1344 | dec->setKind(KDevelop::Declaration::Type); | 1346 | dec->setKind(KDevelop::Declaration::Type); | ||
1345 | dec->clearBaseClasses(); | 1347 | dec->clearBaseClasses(); | ||
1346 | dec->setClassType(ClassDeclarationData::Class); | 1348 | dec->setClassType(ClassDeclarationData::Class); | ||
1347 | 1349 | | |||
1348 | dec->setComment(getDocstring(node->body)); | 1350 | auto docstring = getDocstring(node->body); | ||
1349 | 1351 | dec->setComment(docstring); | |||
1352 | if ( ! docstring.isEmpty() ) { | ||||
1350 | // check whether this is a type container (list, dict, ...) or just a "normal" class | 1353 | // check whether this is a type container (list, dict, ...) or just a "normal" class | ||
1351 | if ( Helper::docstringContainsHint(dec, "TypeContainer") ) { | 1354 | if ( Helper::docstringContainsHint(docstring, "TypeContainer") ) { | ||
1352 | ListType* container = nullptr; | 1355 | ListType* container = nullptr; | ||
1353 | if ( Helper::docstringContainsHint(dec, "hasTypedKeys") ) { | 1356 | if ( Helper::docstringContainsHint(docstring, "hasTypedKeys") ) { | ||
1354 | container = new MapType(); | 1357 | container = new MapType(); | ||
1355 | } | 1358 | } | ||
1356 | else { | 1359 | else { | ||
1357 | container = new ListType(); | 1360 | container = new ListType(); | ||
1358 | } | 1361 | } | ||
1359 | type = StructureType::Ptr(container); | 1362 | type = StructureType::Ptr(container); | ||
1360 | } | 1363 | } | ||
1361 | if ( Helper::docstringContainsHint(dec, "IndexedTypeContainer") ) { | 1364 | if ( Helper::docstringContainsHint(docstring, "IndexedTypeContainer") ) { | ||
1362 | IndexedContainer* container = new IndexedContainer(); | 1365 | IndexedContainer* container = new IndexedContainer(); | ||
1363 | type = StructureType::Ptr(container); | 1366 | type = StructureType::Ptr(container); | ||
1364 | } | 1367 | } | ||
1365 | 1368 | } | |||
1366 | lock.unlock(); | 1369 | lock.unlock(); | ||
1367 | foreach ( ExpressionAst* c, node->baseClasses ) { | 1370 | foreach ( ExpressionAst* c, node->baseClasses ) { | ||
1368 | // Iterate over all the base classes, and add them to the duchain. | 1371 | // Iterate over all the base classes, and add them to the duchain. | ||
1369 | ExpressionVisitor v(currentContext()); | 1372 | ExpressionVisitor v(currentContext()); | ||
1370 | v.visitNode(c); | 1373 | v.visitNode(c); | ||
1371 | if ( v.lastType() && v.lastType()->whichType() == AbstractType::TypeStructure ) { | 1374 | if ( v.lastType() && v.lastType()->whichType() == AbstractType::TypeStructure ) { | ||
1372 | StructureType::Ptr baseClassType = v.lastType().cast<StructureType>(); | 1375 | StructureType::Ptr baseClassType = v.lastType().cast<StructureType>(); | ||
1373 | BaseClassInstance base; | 1376 | BaseClassInstance base; | ||
▲ Show 20 Lines • Show All 528 Lines • Show Last 20 Lines |