| 98 | } |
| 99 | |
| 100 | bool ClangRefactoring::validCandidateToMoveIntoSource(Declaration* decl) |
| 101 | { |
| 102 | if (!decl || !decl->isFunctionDeclaration() || !decl->type<FunctionType>()) { |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | if (!decl->internalContext() || decl->internalContext()->type() != DUContext::Function) { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | if (!decl->isDefinition()) { |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | auto childCtx = decl->internalContext()->childContexts(); |
| 115 | if (childCtx.isEmpty()) { |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | auto ctx = childCtx.first(); |
| 120 | if (!ctx || ctx->type() != DUContext::Other) { |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | auto functionDecl = dynamic_cast<AbstractFunctionDeclaration*>(decl); |
| 125 | if (!functionDecl || functionDecl->isInline()) { |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | QString ClangRefactoring::moveIntoSource(const IndexedDeclaration& iDecl) |
| 133 | { |
nothing calls this directly
no test coverage detected