summaryrefslogtreecommitdiffstats
path: root/languages/cpp/includepathresolver.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:56:07 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:56:07 +0000
commitd6f8bbb45b267065a6907e71ff9c98bb6d161241 (patch)
treed109539636691d7b03036ca1c0ed29dbae6577cf /languages/cpp/includepathresolver.cpp
parent3331a47a9cad24795c7440ee8107143ce444ef34 (diff)
downloadtdevelop-d6f8bbb45b267065a6907e71ff9c98bb6d161241.tar.gz
tdevelop-d6f8bbb45b267065a6907e71ff9c98bb6d161241.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1157658 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/includepathresolver.cpp')
-rw-r--r--languages/cpp/includepathresolver.cpp120
1 files changed, 60 insertions, 60 deletions
diff --git a/languages/cpp/includepathresolver.cpp b/languages/cpp/includepathresolver.cpp
index 117c7732..ebd536ec 100644
--- a/languages/cpp/includepathresolver.cpp
+++ b/languages/cpp/includepathresolver.cpp
@@ -28,8 +28,8 @@
#include <unistd.h>
#include <memory>
#include "kurl.h" /* defines KURL */
-#include "qdir.h" /* defines QDir */
-#include "qregexp.h" /* defines QRegExp */
+#include "tqdir.h" /* defines TQDir */
+#include "tqregexp.h" /* defines TQRegExp */
#include "klocale.h" /* defines [function] i18n */
#include "blockingkprocess.h" /* defines BlockingKProcess */
#include "includepathresolver.h"
@@ -62,8 +62,8 @@ namespace CppTools {
class FileModificationTimeWrapper {
public:
///@param files list of files that should be fake-modified(modtime will be set to current time)
- FileModificationTimeWrapper( const QStringList& files = QStringList() ) : m_newTime( time(0) ) {
- for( QStringList::const_iterator it = files.begin(); it != files.end(); ++it ) {
+ FileModificationTimeWrapper( const TQStringList& files = TQStringList() ) : m_newTime( time(0) ) {
+ for( TQStringList::const_iterator it = files.begin(); it != files.end(); ++it ) {
ifTest( cout << "touching " << (*it).ascii() << endl );
struct stat s;
if( stat( (*it).local8Bit().data(), &s ) == 0 ) {
@@ -85,8 +85,8 @@ namespace CppTools {
}
//Not used yet, might be used to return LD_PRELOAD=.. FAKE_MODIFIED=.. etc. later
- QString commandPrefix() const {
- return QString();
+ TQString commandPrefix() const {
+ return TQString();
}
///Undo changed modification-times
@@ -120,14 +120,14 @@ namespace CppTools {
}
private:
- typedef QMap<QString, struct stat> StatMap;
+ typedef TQMap<TQString, struct stat> StatMap;
StatMap m_stat;
time_t m_newTime;
};
class SourcePathInformation {
public:
- SourcePathInformation( const QString& path ) : m_path( path ), m_isUnsermake(false), m_shouldTouchFiles(false) {
+ SourcePathInformation( const TQString& path ) : m_path( path ), m_isUnsermake(false), m_shouldTouchFiles(false) {
m_isUnsermake = isUnsermakePrivate( path );
ifTest( if( m_isUnsermake ) cout << "unsermake detected" << endl );
@@ -142,7 +142,7 @@ namespace CppTools {
m_shouldTouchFiles = b;
}
- QString getCommand( const QString& sourceFile, const QString& makeParameters ) const {
+ TQString getCommand( const TQString& sourceFile, const TQString& makeParameters ) const {
if( isUnsermake() )
return "unsermake -k --no-real-compare -n " + makeParameters;
else
@@ -150,7 +150,7 @@ namespace CppTools {
}
bool hasMakefile() const {
- QFileInfo makeFile( m_path, "Makefile" );
+ TQFileInfo makeFile( m_path, "Makefile" );
return makeFile.exists();
}
@@ -158,8 +158,8 @@ namespace CppTools {
return isUnsermake() || m_shouldTouchFiles;
}
- QStringList possibleTargets( const QString& targetBaseName ) const {
- QStringList ret;
+ TQStringList possibleTargets( const TQString& targetBaseName ) const {
+ TQStringList ret;
if( isUnsermake() ) {
//unsermake breaks if the first given target does not exist, so in worst-case 2 calls are necessary
ret << targetBaseName + ".lo";
@@ -174,12 +174,12 @@ namespace CppTools {
}
private:
- bool isUnsermakePrivate( const QString& path ) {
+ bool isUnsermakePrivate( const TQString& path ) {
bool ret = false;
- QFileInfo makeFile( path, "Makefile" );
- QFile f( makeFile.absFilePath() );
+ TQFileInfo makeFile( path, "Makefile" );
+ TQFile f( makeFile.absFilePath() );
if( f.open( IO_ReadOnly ) ) {
- QString firstLine;
+ TQString firstLine;
f.readLine( firstLine, 1000 );
if( firstLine.find( "generated by unsermake" ) != -1 ) {
ret = true;
@@ -189,14 +189,14 @@ namespace CppTools {
return ret;
}
- QString m_path;
+ TQString m_path;
bool m_isUnsermake;
bool m_shouldTouchFiles;
};
};
-bool IncludePathResolver::executeCommandPopen ( const QString& command, const QString& workingDirectory, QString& result ) const
+bool IncludePathResolver::executeCommandPopen ( const TQString& command, const TQString& workingDirectory, TQString& result ) const
{
ifTest( cout << "executing " << command.ascii() << endl );
@@ -207,12 +207,12 @@ bool IncludePathResolver::executeCommandPopen ( const QString& command, const QS
const int BUFSIZE = 2048;
char buf [BUFSIZE];
- result = QString();
+ result = TQString();
int status = 1;
if ((fp = popen(command.local8Bit(), "r")) != NULL) {
while (fgets(buf, sizeof (buf), fp))
- result += QString(buf);
+ result += TQString(buf);
status = pclose(fp);
}
@@ -230,12 +230,12 @@ IncludePathResolver::IncludePathResolver( bool continueEventLoop ) : m_isResolvi
}
///More efficient solution: Only do exactly one call for each directory. During that call, mark all source-files as changed, and make all targets for those files.
-PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& file ) {
- QFileInfo fi( file );
+PathResolutionResult IncludePathResolver::resolveIncludePath( const TQString& file ) {
+ TQFileInfo fi( file );
return resolveIncludePath( fi.fileName(), fi.dirPath(true) );
}
-PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& file, const QString& workingDirectory ) {
+PathResolutionResult IncludePathResolver::resolveIncludePath( const TQString& file, const TQString& workingDirectory ) {
struct Enabler {
bool& b;
@@ -253,14 +253,14 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
Enabler e( m_isResolving );
///STEP 1: CACHING
- QDir dir( workingDirectory );
- dir = QDir( dir.absPath() );
- QFileInfo makeFile( dir, "Makefile" );
+ TQDir dir( workingDirectory );
+ dir = TQDir( dir.absPath() );
+ TQFileInfo makeFile( dir, "Makefile" );
if( !makeFile.exists() )
return PathResolutionResult(false, i18n("Makefile is missing in folder \"%1\"").arg(dir.absPath()), i18n("problem while trying to resolve include-paths for %1").arg(file) );
- QStringList cachedPath; //If the call doesn't succeed, use the cached not up-to-date version
- QDateTime makeFileModification = makeFile.lastModified();
+ TQStringList cachedPath; //If the call doesn't succeed, use the cached not up-to-date version
+ TQDateTime makeFileModification = makeFile.lastModified();
Cache::iterator it = m_cache.find( dir.path() );
if( it != m_cache.end() ) {
cachedPath = (*it).path;
@@ -272,7 +272,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
return ret;
} else {
//We have a cached failed result. We should use that for some time but then try again. Return the failed result if: ( there were too many tries within this folder OR this file was already tried ) AND The last tries have not expired yet
- if( /*((*it).failedFiles.size() > 3 || (*it).failedFiles.find( file ) != (*it).failedFiles.end()) &&*/ (*it).failTime.secsTo( QDateTime::currentDateTime() ) < CACHE_FAIL_FOR_SECONDS ) {
+ if( /*((*it).failedFiles.size() > 3 || (*it).failedFiles.find( file ) != (*it).failedFiles.end()) &&*/ (*it).failTime.secsTo( TQDateTime::currentDateTime() ) < CACHE_FAIL_FOR_SECONDS ) {
PathResolutionResult ret(false); //Fake that the result is ok
ret.errorMessage = i18n("Cached: ") + (*it).errorMessage;
ret.longErrorMessage = (*it).longErrorMessage;
@@ -286,10 +286,10 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
}
///STEP 1: Prepare paths
- QString targetName;
- QFileInfo fi( file );
+ TQString targetName;
+ TQFileInfo fi( file );
- QString absoluteFile = file;
+ TQString absoluteFile = file;
if( !file.startsWith("/") )
absoluteFile = dir.path() + "/" + file;
KURL u( absoluteFile );
@@ -302,9 +302,9 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
targetName = file.left( dot );
- QString wd = dir.path();
+ TQString wd = dir.path();
if( !wd.startsWith("/") ) {
- wd = QDir::currentDirPath() + "/" + wd;
+ wd = TQDir::currentDirPath() + "/" + wd;
KURL u( wd );
u.cleanPath();
wd = u.path();
@@ -320,7 +320,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
}
SourcePathInformation source( wd );
- QStringList possibleTargets = source.possibleTargets( targetName );
+ TQStringList possibleTargets = source.possibleTargets( targetName );
source.setShouldTouchFiles(true); //Think about whether this should be always enabled. I've enabled it for now so there's an even bigger chance that everything works.
@@ -329,7 +329,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
///STEP 3.1: Try resolution using the absolute path
PathResolutionResult res;
//Try for each possible target
- for( QStringList::const_iterator it = possibleTargets.begin(); it != possibleTargets.end(); ++it ) {
+ for( TQStringList::const_iterator it = possibleTargets.begin(); it != possibleTargets.end(); ++it ) {
res = resolveIncludePathInternal( absoluteFile, wd, *it, source );
if( res ) break;
}
@@ -346,8 +346,8 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
///STEP 3.2: Try resolution using the relative path
- QString relativeFile = KURL::relativePath(wd, absoluteFile);
- for( QStringList::const_iterator it = possibleTargets.begin(); it != possibleTargets.end(); ++it ) {
+ TQString relativeFile = KURL::relativePath(wd, absoluteFile);
+ for( TQStringList::const_iterator it = possibleTargets.begin(); it != possibleTargets.end(); ++it ) {
res = resolveIncludePathInternal( relativeFile, wd, *it, source );
if( res ) break;
}
@@ -365,7 +365,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
ce.failed = true;
ce.errorMessage = res.errorMessage;
ce.longErrorMessage = res.longErrorMessage;
- ce.failTime = QDateTime::currentDateTime();
+ ce.failTime = TQDateTime::currentDateTime();
ce.failedFiles[file] = true;
} else {
ce.failed = false;
@@ -375,7 +375,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePath( const QString& fil
return res;
}
-PathResolutionResult IncludePathResolver::getFullOutput( const QString& command, const QString& workingDirectory, QString& output ) const{
+PathResolutionResult IncludePathResolver::getFullOutput( const TQString& command, const TQString& workingDirectory, TQString& output ) const{
if( m_continueEventLoop ) {
BlockingKProcess proc;
proc.setWorkingDirectory( workingDirectory );
@@ -397,25 +397,25 @@ PathResolutionResult IncludePathResolver::getFullOutput( const QString& command,
return PathResolutionResult(true);
}
-PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QString& file, const QString& workingDirectory, const QString& makeParameters, const SourcePathInformation& source ) {
+PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const TQString& file, const TQString& workingDirectory, const TQString& makeParameters, const SourcePathInformation& source ) {
- QString processStdout;
+ TQString processStdout;
- QStringList touchFiles;
+ TQStringList touchFiles;
if( source.shouldTouchFiles() )
touchFiles << file;
FileModificationTimeWrapper touch( touchFiles );
- QString fullOutput;
+ TQString fullOutput;
PathResolutionResult res = getFullOutput( source.getCommand( file, makeParameters ), workingDirectory, fullOutput );
if( !res )
return res;
- QRegExp newLineRx("\\\\\\n");
+ TQRegExp newLineRx("\\\\\\n");
fullOutput.replace( newLineRx, "" );
///@todo collect multiple outputs at the same time for performance-reasons
- QString firstLine = fullOutput;
+ TQString firstLine = fullOutput;
int lineEnd;
if( (lineEnd = fullOutput.find('\n')) != -1 )
firstLine.truncate( lineEnd ); //Only look at the first line of output
@@ -428,14 +428,14 @@ PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QStr
///STEP 1: Test if it is a recursive make-call
- QRegExp makeRx( "\\bmake\\s" );
+ TQRegExp makeRx( "\\bmake\\s" );
int offset = 0;
while( (offset = makeRx.search( firstLine, offset )) != -1 )
{
- QString prefix = firstLine.left( offset ).stripWhiteSpace();
+ TQString prefix = firstLine.left( offset ).stripWhiteSpace();
if( prefix.endsWith( "&&") || prefix.endsWith( ";" ) || prefix.isEmpty() )
{
- QString newWorkingDirectory = workingDirectory;
+ TQString newWorkingDirectory = workingDirectory;
///Extract the new working-directory
if( !prefix.isEmpty() ) {
if( prefix.endsWith( "&&" ) )
@@ -452,14 +452,14 @@ PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QStr
newWorkingDirectory = u.path();
}
}
- QFileInfo d( newWorkingDirectory );
+ TQFileInfo d( newWorkingDirectory );
if( d.exists() ) {
///The recursive working-directory exists.
- QString makeParams = firstLine.mid( offset+5 );
+ TQString makeParams = firstLine.mid( offset+5 );
if( !makeParams.contains( ";" ) && !makeParams.contains( "&&" ) ) {
///Looks like valid parameters
///Make the file-name absolute, so it can be referenced from any directory
- QString absoluteFile = file;
+ TQString absoluteFile = file;
if( !absoluteFile.startsWith("/") )
absoluteFile = workingDirectory + "/" + file;
KURL u( absoluteFile );
@@ -486,18 +486,18 @@ PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QStr
}
///STEP 2: Search the output for include-paths
- QRegExp validRx( "\\b([cg]\\+\\+|gcc)" );
+ TQRegExp validRx( "\\b([cg]\\+\\+|gcc)" );
if( validRx.search( fullOutput ) == -1 )
return PathResolutionResult( false, i18n("Output seems not to be a valid gcc or g++ call"), i18n("Folder: \"%1\" Command: \"%2\" Output: \"%3\"").arg(workingDirectory).arg( source.getCommand(file, makeParameters) ).arg(fullOutput) );
PathResolutionResult ret( true );
ret.longErrorMessage = fullOutput;
- QString includeParameterRx( "\\s(-I|--include-dir=|-I\\s)" );
- QString quotedRx( "(\\').*(\\')|(\\\").*(\\\")" ); //Matches "hello", 'hello', 'hello"hallo"', etc.
- QString escapedPathRx( "(([^)(\"'\\s]*)(\\\\\\s)?)*" ); //Matches /usr/I\ am \ a\ strange\ path/include
+ TQString includeParameterRx( "\\s(-I|--include-dir=|-I\\s)" );
+ TQString quotedRx( "(\\').*(\\')|(\\\").*(\\\")" ); //Matches "hello", 'hello', 'hello"hallo"', etc.
+ TQString escapedPathRx( "(([^)(\"'\\s]*)(\\\\\\s)?)*" ); //Matches /usr/I\ am \ a\ strange\ path/include
- QRegExp includeRx( QString( "%1(%2|%3)(?=\\s)" ).arg( includeParameterRx ).arg( quotedRx ).arg( escapedPathRx ) );
+ TQRegExp includeRx( TQString( "%1(%2|%3)(?=\\s)" ).arg( includeParameterRx ).arg( quotedRx ).arg( escapedPathRx ) );
includeRx.setMinimal( true );
includeRx.setCaseSensitive( true );
offset = 0;
@@ -519,7 +519,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QStr
int start = offset + pathOffset;
int end = offset + includeRx.matchedLength();
- QString path = fullOutput.mid( start, end-start ).stripWhiteSpace();
+ TQString path = fullOutput.mid( start, end-start ).stripWhiteSpace();
if( path.startsWith( "\"") || path.startsWith( "\'") && path.length() > 2 ) {
//probable a quoted path
if( path.endsWith(path.left(1)) ) {
@@ -542,7 +542,7 @@ PathResolutionResult IncludePathResolver::resolveIncludePathInternal( const QStr
return ret;
}
-void IncludePathResolver::setOutOfSourceBuildSystem( const QString& source, const QString& build ) {
+void IncludePathResolver::setOutOfSourceBuildSystem( const TQString& source, const TQString& build ) {
m_outOfSource = true;
m_source = source;
m_build = build;
@@ -554,7 +554,7 @@ void IncludePathResolver::setOutOfSourceBuildSystem( const QString& source, cons
* */
int main(int argc, char **argv) {
- QApplication app(argc,argv);
+ TQApplication app(argc,argv);
IncludePathResolver resolver;
if( argc < 3 ) {
cout << "params: 1. file-name, 2. working-directory [3. source-directory 4. build-directory]" << endl;