Changeset View
Changeset View
Standalone View
Standalone View
languages/clang/codegen/adaptsignatureassistant.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 106 | { | |||
---|---|---|---|---|---|
117 | DUChainReadLocker lock(DUChain::lock(), 300); | 117 | DUChainReadLocker lock(DUChain::lock(), 300); | ||
118 | if (!lock.locked()) { | 118 | if (!lock.locked()) { | ||
119 | clangDebug() << "failed to lock duchain in time"; | 119 | clangDebug() << "failed to lock duchain in time"; | ||
120 | return; | 120 | return; | ||
121 | } | 121 | } | ||
122 | KTextEditor::Range simpleInvocationRange = KTextEditor::Range(sigAssistRange); | 122 | KTextEditor::Range simpleInvocationRange = KTextEditor::Range(sigAssistRange); | ||
123 | Declaration* funDecl = getDeclarationAtCursor(simpleInvocationRange.start(), m_document); | 123 | Declaration* funDecl = getDeclarationAtCursor(simpleInvocationRange.start(), m_document); | ||
124 | if (!funDecl || !funDecl->type<FunctionType>()) { | 124 | if (!funDecl || !funDecl->type<FunctionType>()) { | ||
125 | clangDebug() << "No function at cursor"; | ||||
125 | return; | 126 | return; | ||
126 | } | 127 | } | ||
127 | /* | 128 | /* | ||
128 | TODO: Port? | 129 | TODO: Port? | ||
129 | if(QtFunctionDeclaration* classFun = dynamic_cast<QtFunctionDeclaration*>(funDecl)) { | 130 | if(QtFunctionDeclaration* classFun = dynamic_cast<QtFunctionDeclaration*>(funDecl)) { | ||
130 | if (classFun->isSignal()) { | 131 | if (classFun->isSignal()) { | ||
131 | // do not offer to change signature of a signal, as the implementation will be generated by moc | 132 | // do not offer to change signature of a signal, as the implementation will be generated by moc | ||
132 | return; | 133 | return; | ||
133 | } | 134 | } | ||
134 | } | 135 | } | ||
135 | */ | 136 | */ | ||
136 | 137 | | |||
137 | Declaration* otherSide = 0; | 138 | Declaration* otherSide = 0; | ||
138 | FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(funDecl); | 139 | FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(funDecl); | ||
139 | if (definition) { | 140 | if (definition) { | ||
140 | m_editingDefinition = true; | 141 | m_editingDefinition = true; | ||
141 | otherSide = definition->declaration(); | 142 | otherSide = definition->declaration(); | ||
142 | } else if ((definition = FunctionDefinition::definition(funDecl))) { | 143 | } else if ((definition = FunctionDefinition::definition(funDecl))) { | ||
143 | m_editingDefinition = false; | 144 | m_editingDefinition = false; | ||
144 | otherSide = definition; | 145 | otherSide = definition; | ||
145 | } | 146 | } | ||
146 | if (!otherSide) { | 147 | if (!otherSide) { | ||
148 | clangDebug() << "no other side for signature found"; | ||||
147 | return; | 149 | return; | ||
148 | } | 150 | } | ||
149 | m_otherSideContext = DUContextPointer(DUChainUtils::getFunctionContext(otherSide)); | 151 | m_otherSideContext = DUContextPointer(DUChainUtils::getFunctionContext(otherSide)); | ||
150 | if (!m_otherSideContext) { | 152 | if (!m_otherSideContext) { | ||
153 | clangDebug() << "no context for other side found"; | ||||
151 | return; | 154 | return; | ||
152 | } | 155 | } | ||
153 | m_declarationName = funDecl->identifier(); | 156 | m_declarationName = funDecl->identifier(); | ||
154 | m_otherSideId = otherSide->id(); | 157 | m_otherSideId = otherSide->id(); | ||
155 | m_otherSideTopContext = ReferencedTopDUContext(otherSide->topContext()); | 158 | m_otherSideTopContext = ReferencedTopDUContext(otherSide->topContext()); | ||
156 | m_oldSignature = getDeclarationSignature(otherSide, m_otherSideContext.data(), true); | 159 | m_oldSignature = getDeclarationSignature(otherSide, m_otherSideContext.data(), true); | ||
157 | 160 | | |||
158 | //Schedule an update, to make sure the ranges match | 161 | //Schedule an update, to make sure the ranges match | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 283 | #endif | |||
281 | 284 | | |||
282 | //ParseJob having finished, get the signature that was modified | 285 | //ParseJob having finished, get the signature that was modified | ||
283 | Signature newSignature = getDeclarationSignature(functionDecl, functionCtxt, false); | 286 | Signature newSignature = getDeclarationSignature(functionDecl, functionCtxt, false); | ||
284 | 287 | | |||
285 | //Check for changes between m_oldSignature and newSignature, use oldPositions to store old<->new param index mapping | 288 | //Check for changes between m_oldSignature and newSignature, use oldPositions to store old<->new param index mapping | ||
286 | QList<int> oldPositions; | 289 | QList<int> oldPositions; | ||
287 | if (!getSignatureChanges(newSignature, oldPositions)) { | 290 | if (!getSignatureChanges(newSignature, oldPositions)) { | ||
288 | reset(); | 291 | reset(); | ||
292 | clangDebug() << "no changes to signature"; | ||||
289 | return; //No changes to signature | 293 | return; //No changes to signature | ||
290 | } | 294 | } | ||
291 | QList<RenameAction*> renameActions; | 295 | QList<RenameAction*> renameActions; | ||
292 | if (m_editingDefinition) { | 296 | if (m_editingDefinition) { | ||
293 | setDefaultParams(newSignature, oldPositions); //restore default parameters before updating the declarations | 297 | setDefaultParams(newSignature, oldPositions); //restore default parameters before updating the declarations | ||
294 | } else { | 298 | } else { | ||
295 | renameActions = getRenameActions(newSignature, oldPositions); //rename as needed when updating the definition | 299 | renameActions = getRenameActions(newSignature, oldPositions); //rename as needed when updating the definition | ||
296 | } | 300 | } | ||
Show All 10 Lines |