Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/cmake/cmakecodecompletionmodel.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 54 | { | |||
---|---|---|---|---|---|
55 | return decl->abstractType().cast<FunctionType>(); | 55 | return decl->abstractType().cast<FunctionType>(); | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | bool isPathChar(const QChar& c) | 58 | bool isPathChar(const QChar& c) | ||
59 | { | 59 | { | ||
60 | return c.isLetterOrNumber() || c=='/' || c=='.'; | 60 | return c.isLetterOrNumber() || c=='/' || c=='.'; | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | QString escapePath(QString path) | ||||
64 | { | ||||
65 | static const QChar toBeEscaped[] = {'(', ')'}; | ||||
kfunk: `static ...` | |||||
66 | for(const QChar &ch : toBeEscaped) | ||||
67 | { | ||||
68 | path.replace(ch, "\\" + ch); | ||||
69 | } | ||||
70 | return path; | ||||
71 | } | ||||
72 | | ||||
63 | void CMakeCodeCompletionModel::completionInvoked(View* view, const Range& range, InvocationType invocationType) | 73 | void CMakeCodeCompletionModel::completionInvoked(View* view, const Range& range, InvocationType invocationType) | ||
64 | { | 74 | { | ||
65 | beginResetModel(); | 75 | beginResetModel(); | ||
66 | if(s_commands.isEmpty()) { | 76 | if(s_commands.isEmpty()) { | ||
67 | ICMakeDocumentation* cmakedoc=CMake::cmakeDocumentation(); | 77 | ICMakeDocumentation* cmakedoc=CMake::cmakeDocumentation(); | ||
68 | 78 | | |||
69 | if(cmakedoc) | 79 | if(cmakedoc) | ||
70 | s_commands=cmakedoc->names(ICMakeDocumentation::Command); | 80 | s_commands=cmakedoc->names(ICMakeDocumentation::Command); | ||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | 279 | { | |||
271 | const int row = idx.row(); | 281 | const int row = idx.row(); | ||
272 | switch(indexType(row)) | 282 | switch(indexType(row)) | ||
273 | { | 283 | { | ||
274 | case Path: { | 284 | case Path: { | ||
275 | Range r=word; | 285 | Range r=word; | ||
276 | for(QChar c=document->characterAt(r.end()); c.isLetterOrNumber() || c=='.'; c=document->characterAt(r.end())) { | 286 | for(QChar c=document->characterAt(r.end()); c.isLetterOrNumber() || c=='.'; c=document->characterAt(r.end())) { | ||
277 | r.setEnd(KTextEditor::Cursor(r.end().line(), r.end().column()+1)); | 287 | r.setEnd(KTextEditor::Cursor(r.end().line(), r.end().column()+1)); | ||
278 | } | 288 | } | ||
279 | document->replaceText(r, data(index(row, Name, QModelIndex())).toString()); | 289 | QString path = data(index(row, Name, QModelIndex())).toString(); | ||
290 | | ||||
291 | document->replaceText(r, escapePath(path)); | ||||
280 | } break; | 292 | } break; | ||
281 | case Macro: | 293 | case Macro: | ||
282 | case Command: { | 294 | case Command: { | ||
283 | QString code=data(index(row, Name, QModelIndex())).toString(); | 295 | QString code=data(index(row, Name, QModelIndex())).toString(); | ||
284 | if(!document->line(word.start().line()).contains('(')) | 296 | if(!document->line(word.start().line()).contains('(')) | ||
285 | code.append('('); | 297 | code.append('('); | ||
286 | 298 | | |||
287 | document->replaceText(word, code); | 299 | document->replaceText(word, code); | ||
Show All 18 Lines |
static ...