26
26
#include <interfaces/icore.h>
27
27
#include <interfaces/iprojectcontroller.h>
28
28
#include <interfaces/iproject.h>
29
#include <interfaces/idocumentcontroller.h>
30
#include <interfaces/idocument.h>
32
30
#include <language/codegen/coderepresentation.h>
33
31
#include <language/duchain/declaration.h>
42
40
#include <QDirIterator>
44
//List of possible headers used for definition/declaration fallback switching
45
QStringList headerExtensions(QString("h,H,hh,hxx,hpp,tlh,h++").split(','));
46
QStringList sourceExtensions(QString("c,cc,cpp,c++,cxx,C,m,mm,M,inl,_impl.h").split(','));
49
43
QList<T> makeListUnique(QList<T> list)
122
116
possibleExts << "h";
124
118
// if file is a header file search for implementation file
125
else if ( headerExtensions.contains( ext ) )
119
else if ( headerExtensions().contains( ext ) )
127
foreach(const QString& ext, sourceExtensions)
121
foreach(const QString& ext, sourceExtensions())
128
122
candidates << ( base + addDot(ext) );
130
possibleExts = sourceExtensions;
124
possibleExts = sourceExtensions();
132
126
// if file is an implementation file, search for header file
133
else if ( sourceExtensions.contains( ext ) )
127
else if ( sourceExtensions().contains( ext ) )
135
foreach(const QString& ext, headerExtensions)
129
foreach(const QString& ext, headerExtensions())
136
130
candidates << ( base + addDot(ext) );
138
possibleExts = headerExtensions;
132
possibleExts = headerExtensions();
140
134
// search for files from the assembled candidate lists, return the first
141
135
// candidate file that actually exists or QString::null if nothing is found.
364
358
if(item.name.startsWith('.') || item.name.endsWith("~")) //This filters out ".", "..", and hidden files, and backups
366
360
QString suffix = dirContent.fileInfo().suffix();
367
if(!dirContent.fileInfo().suffix().isEmpty() && !headerExtensions.contains(suffix) && (!allowSourceFiles || !sourceExtensions.contains(suffix)))
361
if(!dirContent.fileInfo().suffix().isEmpty() && !headerExtensions().contains(suffix) && (!allowSourceFiles || !sourceExtensions().contains(suffix)))
370
364
QString fullPath = dirContent.fileInfo().canonicalFilePath();
395
void ReplaceCurrentAccess::exec(KUrl url, QString old, QString _new)
397
IDocument* document = ICore::self()->documentController()->documentForUrl(url);
399
KTextEditor::Document* textDocument = document->textDocument();
401
KTextEditor::View* activeView = textDocument->activeView();
403
KTextEditor::Cursor cursor = activeView->cursorPosition();
406
static KTextEditor::Cursor lastPos;
407
static QString lastOld;
408
static QString lastNew;
409
if(lastUrl == url && lastPos == cursor)
411
kDebug() << "Not doing the same access replacement twice at" << lastUrl << lastPos;
419
KTextEditor::Range oldRange = KTextEditor::Range(cursor-KTextEditor::Cursor(0,old.length()), cursor);
420
if(oldRange.start().column() >= 0 && textDocument->text(oldRange) == old) {
421
textDocument->replaceText(oldRange, _new);
430
#include "cpputils.moc"
388
QStringList headerExtensions()
390
static const QStringList headerExtensions = QString("h,H,hh,hxx,hpp,tlh,h++").split(',');
391
return headerExtensions;
394
QStringList sourceExtensions()
396
static const QStringList sourceExtensions = QString("c,cc,cpp,c++,cxx,C,m,mm,M,inl,_impl.h").split(',');
397
return sourceExtensions;