~ubuntu-branches/ubuntu/trusty/kdevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to languages/cpp/cpputils.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2013-12-09 18:54:59 UTC
  • mfrom: (1.7.19)
  • Revision ID: package-import@ubuntu.com-20131209185459-zlxv7jo7up8gthne
Tags: 4:4.6.0-0ubuntu1
* New upstream release (LP: #1259220)
* Update install files 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
31
29
 
32
30
#include <language/codegen/coderepresentation.h>
33
31
#include <language/duchain/declaration.h>
41
39
 
42
40
#include <QDirIterator>
43
41
 
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(','));
47
 
 
48
42
template<class T>
49
43
QList<T> makeListUnique(QList<T> list)
50
44
{
122
116
    possibleExts << "h";
123
117
  }
124
118
  // if file is a header file search for implementation file
125
 
  else if ( headerExtensions.contains( ext ) )
 
119
  else if ( headerExtensions().contains( ext ) )
126
120
  {
127
 
    foreach(const QString& ext, sourceExtensions)
 
121
    foreach(const QString& ext, sourceExtensions())
128
122
      candidates << ( base + addDot(ext) );
129
123
 
130
 
    possibleExts = sourceExtensions;
 
124
    possibleExts = sourceExtensions();
131
125
  }
132
126
  // if file is an implementation file, search for header file
133
 
  else if ( sourceExtensions.contains( ext ) )
 
127
  else if ( sourceExtensions().contains( ext ) )
134
128
  {
135
 
    foreach(const QString& ext, headerExtensions)
 
129
    foreach(const QString& ext, headerExtensions())
136
130
      candidates << ( base + addDot(ext) );
137
131
 
138
 
    possibleExts = headerExtensions;
 
132
    possibleExts = headerExtensions();
139
133
  }
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.
195
189
  if ( ext.isEmpty() )
196
190
    return true;
197
191
  
198
 
  return headerExtensions.contains(ext);
 
192
  return headerExtensions().contains(ext);
199
193
}
200
194
 
201
195
QStringList standardIncludePaths()
364
358
            if(item.name.startsWith('.') || item.name.endsWith("~")) //This filters out ".", "..", and hidden files, and backups
365
359
              continue;
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)))
368
362
              continue;
369
363
            
370
364
            QString fullPath = dirContent.fileInfo().canonicalFilePath();
391
385
    return ret;
392
386
}
393
387
 
394
 
 
395
 
void ReplaceCurrentAccess::exec(KUrl url, QString old, QString _new)
396
 
{
397
 
  IDocument* document = ICore::self()->documentController()->documentForUrl(url);
398
 
  if(document) {
399
 
    KTextEditor::Document* textDocument = document->textDocument();
400
 
    if(textDocument) {
401
 
      KTextEditor::View* activeView = textDocument->activeView();
402
 
      if(activeView) {
403
 
        KTextEditor::Cursor cursor = activeView->cursorPosition();
404
 
        
405
 
        static KUrl lastUrl;
406
 
        static KTextEditor::Cursor lastPos;
407
 
        static QString lastOld;
408
 
        static QString lastNew;
409
 
        if(lastUrl == url && lastPos == cursor)
410
 
        {
411
 
          kDebug() << "Not doing the same access replacement twice at" << lastUrl << lastPos;
412
 
          return;
413
 
        }
414
 
        lastUrl = url;
415
 
        lastPos = cursor;
416
 
        lastOld = old;
417
 
        lastNew = _new;
418
 
        
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);
422
 
        }
423
 
      }
424
 
    }
425
 
  }
426
 
}
427
 
 
428
 
}
429
 
 
430
 
#include "cpputils.moc"
 
388
QStringList headerExtensions()
 
389
{
 
390
  static const QStringList headerExtensions = QString("h,H,hh,hxx,hpp,tlh,h++").split(',');
 
391
  return headerExtensions;
 
392
}
 
393
 
 
394
QStringList sourceExtensions()
 
395
{
 
396
  static const QStringList sourceExtensions = QString("c,cc,cpp,c++,cxx,C,m,mm,M,inl,_impl.h").split(',');
 
397
  return sourceExtensions;
 
398
}
 
399
 
 
400
}