Changeset View
Changeset View
Standalone View
Standalone View
duchain/helper.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 103 | } else if (declarationType == ClassDeclarationType && id == staticQId) { | |||
---|---|---|---|---|---|
107 | } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) { | 107 | } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) { | ||
108 | return DeclarationPointer(currentContext->parentContext()->owner()); | 108 | return DeclarationPointer(currentContext->parentContext()->owner()); | ||
109 | } else { | 109 | } else { | ||
110 | return DeclarationPointer(); | 110 | return DeclarationPointer(); | ||
111 | } | 111 | } | ||
112 | } else if (declarationType == ClassDeclarationType && id == parentQId) { | 112 | } else if (declarationType == ClassDeclarationType && id == parentQId) { | ||
113 | //there can be just one Class-Context imported | 113 | //there can be just one Class-Context imported | ||
114 | DUChainReadLocker lock; | 114 | DUChainReadLocker lock; | ||
115 | DUContext* classCtx = 0; | 115 | DUContext* classCtx = nullptr; | ||
116 | if (currentContext->type() == DUContext::Class) { | 116 | if (currentContext->type() == DUContext::Class) { | ||
117 | classCtx = currentContext; | 117 | classCtx = currentContext; | ||
118 | } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) { | 118 | } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) { | ||
119 | classCtx = currentContext->parentContext(); | 119 | classCtx = currentContext->parentContext(); | ||
120 | } | 120 | } | ||
121 | if (classCtx) { | 121 | if (classCtx) { | ||
122 | foreach(const DUContext::Import &i, classCtx->importedParentContexts()) { | 122 | foreach(const DUContext::Import &i, classCtx->importedParentContexts()) { | ||
123 | DUContext* ctx = i.context(classCtx->topContext()); | 123 | DUContext* ctx = i.context(classCtx->topContext()); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
176 | ifDebug(qCDebug(DUCHAIN) << "returning 0";) | 176 | ifDebug(qCDebug(DUCHAIN) << "returning 0";) | ||
177 | return DeclarationPointer(); | 177 | return DeclarationPointer(); | ||
178 | } | 178 | } | ||
179 | 179 | | |||
180 | DeclarationPointer findDeclarationInPST(DUContext* currentContext, QualifiedIdentifier id, DeclarationType declarationType) | 180 | DeclarationPointer findDeclarationInPST(DUContext* currentContext, QualifiedIdentifier id, DeclarationType declarationType) | ||
181 | { | 181 | { | ||
182 | ifDebug(qCDebug(DUCHAIN) << "PST: " << id.toString() << declarationType;) | 182 | ifDebug(qCDebug(DUCHAIN) << "PST: " << id.toString() << declarationType;) | ||
183 | uint nr; | 183 | uint nr; | ||
184 | const IndexedDeclaration* declarations = 0; | 184 | const IndexedDeclaration* declarations = nullptr; | ||
185 | DUChainWriteLocker wlock; | 185 | DUChainWriteLocker wlock; | ||
186 | PersistentSymbolTable::self().declarations(id, nr, declarations); | 186 | PersistentSymbolTable::self().declarations(id, nr, declarations); | ||
187 | ifDebug(qCDebug(DUCHAIN) << "found declarations:" << nr;) | 187 | ifDebug(qCDebug(DUCHAIN) << "found declarations:" << nr;) | ||
188 | /// Indexed string for 'Php', identifies environment files from this language plugin | 188 | /// Indexed string for 'Php', identifies environment files from this language plugin | ||
189 | static const IndexedString phpLangString("Php"); | 189 | static const IndexedString phpLangString("Php"); | ||
190 | 190 | | |||
191 | for (uint i = 0; i < nr; ++i) { | 191 | for (uint i = 0; i < nr; ++i) { | ||
192 | ParsingEnvironmentFilePointer env = DUChain::self()->environmentFileForDocument(declarations[i].indexedTopContext()); | 192 | ParsingEnvironmentFilePointer env = DUChain::self()->environmentFileForDocument(declarations[i].indexedTopContext()); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 251 | { | |||
252 | return KDevelop::formatComment(editor->parseSession()->docComment(node->startToken).toUtf8()); | 252 | return KDevelop::formatComment(editor->parseSession()->docComment(node->startToken).toUtf8()); | ||
253 | } | 253 | } | ||
254 | 254 | | |||
255 | //Helper visitor to extract a commonScalar node | 255 | //Helper visitor to extract a commonScalar node | ||
256 | //used to get the value of an function call argument | 256 | //used to get the value of an function call argument | ||
257 | class ScalarExpressionVisitor : public DefaultVisitor | 257 | class ScalarExpressionVisitor : public DefaultVisitor | ||
258 | { | 258 | { | ||
259 | public: | 259 | public: | ||
260 | ScalarExpressionVisitor() : m_node(0) {} | 260 | ScalarExpressionVisitor() : m_node(nullptr) {} | ||
261 | CommonScalarAst* node() const { | 261 | CommonScalarAst* node() const { | ||
262 | return m_node; | 262 | return m_node; | ||
263 | } | 263 | } | ||
264 | private: | 264 | private: | ||
265 | virtual void visitCommonScalar(CommonScalarAst* node) { | 265 | void visitCommonScalar(CommonScalarAst* node) override { | ||
266 | m_node = node; | 266 | m_node = node; | ||
267 | } | 267 | } | ||
268 | CommonScalarAst* m_node; | 268 | CommonScalarAst* m_node; | ||
269 | }; | 269 | }; | ||
270 | 270 | | |||
271 | CommonScalarAst* findCommonScalar(AstNode* node) | 271 | CommonScalarAst* findCommonScalar(AstNode* node) | ||
272 | { | 272 | { | ||
273 | ScalarExpressionVisitor visitor; | 273 | ScalarExpressionVisitor visitor; | ||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |