Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/codecompletion/codecompletionhelper.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 32 | { | |||
---|---|---|---|---|---|
46 | if( declaration->kind() == Declaration::Type || (funcType && funcType->indexedArgumentsSize()) ) | 46 | if( declaration->kind() == Declaration::Type || (funcType && funcType->indexedArgumentsSize()) ) | ||
47 | haveArguments = true; | 47 | haveArguments = true; | ||
48 | 48 | | |||
49 | if( declaration->kind() == Declaration::Instance && !declaration->isFunctionDeclaration()) | 49 | if( declaration->kind() == Declaration::Instance && !declaration->isFunctionDeclaration()) | ||
50 | haveArguments = true; //probably a constructor initializer | 50 | haveArguments = true; //probably a constructor initializer | ||
51 | 51 | | |||
52 | //Need to have a paren behind | 52 | //Need to have a paren behind | ||
53 | QString suffix = view->document()->text( KTextEditor::Range( pos, pos + KTextEditor::Cursor(1, 0) ) ); | 53 | QString suffix = view->document()->text( KTextEditor::Range( pos, pos + KTextEditor::Cursor(1, 0) ) ); | ||
54 | if( suffix.trimmed().startsWith('(') ) { | 54 | if (suffix.trimmed().startsWith(QLatin1Char('('))) { | ||
55 | //Move the cursor behind the opening paren | 55 | //Move the cursor behind the opening paren | ||
56 | if( view ) | 56 | if( view ) | ||
57 | view->setCursorPosition( pos + KTextEditor::Cursor( 0, suffix.indexOf('(')+1 ) ); | 57 | view->setCursorPosition(pos + KTextEditor::Cursor(0, suffix.indexOf(QLatin1Char('(')) + 1)); | ||
58 | }else{ | 58 | }else{ | ||
59 | //We need to insert an opening paren | 59 | //We need to insert an opening paren | ||
60 | QString openingParen; | 60 | QString openingParen; | ||
61 | if( spaceBeforeParen ) | 61 | if( spaceBeforeParen ) | ||
62 | openingParen = QStringLiteral(" ("); | 62 | openingParen = QStringLiteral(" ("); | ||
63 | else | 63 | else | ||
64 | openingParen = '('; | 64 | openingParen = QLatin1Char('('); | ||
65 | 65 | | |||
66 | if( spaceBetweenParens && (haveArguments || spaceBetweenEmptyParens) ) | 66 | if( spaceBetweenParens && (haveArguments || spaceBetweenEmptyParens) ) | ||
67 | openingParen += ' '; | 67 | openingParen += QLatin1Char(' '); | ||
68 | 68 | | |||
69 | QString closingParen; | 69 | QString closingParen; | ||
70 | if( spaceBetweenParens && (haveArguments) ) { | 70 | if( spaceBetweenParens && (haveArguments) ) { | ||
71 | closingParen = QStringLiteral(" )"); | 71 | closingParen = QStringLiteral(" )"); | ||
72 | } else | 72 | } else | ||
73 | closingParen = ')'; | 73 | closingParen = QLatin1Char(')'); | ||
74 | 74 | | |||
75 | KTextEditor::Cursor jumpPos = pos + KTextEditor::Cursor( 0, openingParen.length() ); | 75 | KTextEditor::Cursor jumpPos = pos + KTextEditor::Cursor( 0, openingParen.length() ); | ||
76 | 76 | | |||
77 | // when function returns void, also add a semicolon | 77 | // when function returns void, also add a semicolon | ||
78 | if (funcType) { | 78 | if (funcType) { | ||
79 | if (IntegralType::Ptr type = funcType->returnType().cast<IntegralType>()) { | 79 | if (IntegralType::Ptr type = funcType->returnType().cast<IntegralType>()) { | ||
80 | if (type->dataType() == IntegralType::TypeVoid) { | 80 | if (type->dataType() == IntegralType::TypeVoid) { | ||
81 | const QChar nextChar = view->document()->characterAt(pos); | 81 | const QChar nextChar = view->document()->characterAt(pos); | ||
82 | if (nextChar != ';' && nextChar != ')' && nextChar != ',') { | 82 | if (nextChar != QLatin1Char(';') && nextChar != QLatin1Char(')') && nextChar != QLatin1Char(',')) { | ||
83 | closingParen += ';'; | 83 | closingParen += QLatin1Char(';'); | ||
84 | } | 84 | } | ||
85 | } | 85 | } | ||
86 | } | 86 | } | ||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | //If no arguments, move the cursor behind the closing paren (or semicolon) | 89 | //If no arguments, move the cursor behind the closing paren (or semicolon) | ||
90 | if( !haveArguments ) | 90 | if( !haveArguments ) | ||
91 | jumpPos += KTextEditor::Cursor( 0, closingParen.length() ); | 91 | jumpPos += KTextEditor::Cursor( 0, closingParen.length() ); | ||
Show All 14 Lines |