Changeset View
Changeset View
Standalone View
Standalone View
duchain/helpers.cpp
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | |||||
153 | AbstractType::Ptr Helper::extractTypeHints(AbstractType::Ptr type) | 153 | AbstractType::Ptr Helper::extractTypeHints(AbstractType::Ptr type) | ||
154 | { | 154 | { | ||
155 | return Helper::foldTypes(Helper::filterType<AbstractType>(type, [](AbstractType::Ptr t) -> bool { | 155 | return Helper::foldTypes(Helper::filterType<AbstractType>(type, [](AbstractType::Ptr t) -> bool { | ||
156 | auto hint = t.cast<HintedType>(); | 156 | auto hint = t.cast<HintedType>(); | ||
157 | return !hint || hint->isValid(); | 157 | return !hint || hint->isValid(); | ||
158 | })); | 158 | })); | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | Helper::FuncInfo Helper::functionDeclarationForCalledDeclaration(DeclarationPointer ptr) | 161 | Helper::FuncInfo Helper::functionForCalled(Declaration* called ) | ||
162 | { | 162 | { | ||
163 | if ( ! ptr ) { | 163 | if ( ! called ) { | ||
164 | return FuncInfo(); | 164 | return { nullptr, false }; | ||
165 | } | 165 | } | ||
166 | else if ( auto functionDecl = FunctionDeclarationPointer(ptr) ) { | 166 | else if ( called->isFunctionDeclaration() ) { | ||
167 | return FuncInfo(functionDecl, false); | 167 | return { static_cast<FunctionDeclaration*>( called ), false }; | ||
168 | } | 168 | } | ||
169 | else { | 169 | else { | ||
170 | // not a function -- try looking for a constructor | 170 | // not a function -- try looking for a constructor | ||
171 | static const IndexedIdentifier initIdentifier(KDevelop::Identifier("__init__")); | 171 | static const IndexedIdentifier initIdentifier(KDevelop::Identifier("__init__")); | ||
172 | auto attr = accessAttribute(ptr->abstractType(), initIdentifier, ptr->topContext()); | 172 | auto attr = accessAttribute( called->abstractType(), initIdentifier, called->topContext()); | ||
173 | return FuncInfo(FunctionDeclarationPointer(attr), true); | 173 | return { dynamic_cast<FunctionDeclaration*>(attr), true }; | ||
174 | } | 174 | } | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | Declaration* Helper::declarationForName(const QualifiedIdentifier& identifier, const RangeInRevision& nodeRange, | 177 | Declaration* Helper::declarationForName(const QualifiedIdentifier& identifier, const RangeInRevision& nodeRange, | ||
178 | KDevelop::DUChainPointer<const DUContext> context) | 178 | KDevelop::DUChainPointer<const DUContext> context) | ||
179 | { | 179 | { | ||
180 | QList<Declaration*> declarations; | 180 | QList<Declaration*> declarations; | ||
181 | QList<Declaration*> localDeclarations; | 181 | QList<Declaration*> localDeclarations; | ||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |