Removed usage of Symbol::endOffset().

This commit is contained in:
Erik Verbruggen
2010-07-16 16:01:19 +02:00
parent cb4104e171
commit 3bcfa87b90

View File

@@ -334,16 +334,24 @@ static void addDeclaration(Document::Ptr doc, const Class *cl, const QString &fu
if (const Function *fun = decl->type()->asFunctionType()) { if (const Function *fun = decl->type()->asFunctionType()) {
// we are only interested in declarations of methods. // we are only interested in declarations of methods.
if (fun->isSlot() && fun->isPrivate()) { if (fun->isSlot() && fun->isPrivate()) {
//
// ### FIXME: change this to use the Refactoring changes and the AST to find the correct insertion position
//
const int line = fun->line(); // this is the beginning of function name: "void ^foo(...)" const int line = fun->line(); // this is the beginning of function name: "void ^foo(...)"
const int column = fun->column(); const int column = 0;
if (ITextEditable *editable = editableAt(docFileName, line, column)) { if (ITextEditable *editable = editableAt(docFileName, line, column)) {
unsigned dl, dc; // this position is the beginning of return value: "^void foo(...)" BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(editable->widget());
unit->getPosition(decl->startOffset(), &dl, &dc); if (editor) {
dc--; // if the first character in line is 'v' coming from "void" getStartPosition returns 1, not 0, so we always decrement it. QTextCursor tc = editor->textCursor();
editable->gotoLine(dl, dc); int pos = tc.position();
editable->position(ITextEditor::StartOfLine); tc.beginEditBlock();
const QString indentation = QString(dc, QLatin1Char(' ')); tc.insertText(declaration);
editable->insert(declaration + indentation); tc.setPosition(pos, QTextCursor::KeepAnchor);
editor->indentInsertedText(tc);
tc.endEditBlock();
}
} }
return; return;
} }