diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ca26827 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test on Windows Self-Hosted Runner + +on: + workflow_dispatch: + +jobs: + test: + name: Run Python and Echo Lines + runs-on: [self-hosted, windows-runner] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Echo multiple lines + run: | + echo Line 1: Hello from the runner + echo Line 2: This is a test + echo Line 3: Echoing multiple lines + shell: cmd + + - name: Run Python script + run: | + import sys + print("Python is working!") + print("Version:", sys.version) + shell: python diff --git a/check-clang.pri b/check-clang.pri index 621d510..57bac41 100644 --- a/check-clang.pri +++ b/check-clang.pri @@ -3,15 +3,15 @@ # Clang installation. # -REQUIRED_CLANG_VERSION = 3.8 +REQUIRED_CLANG_VERSION = 5.0.0 equals(CLANG_DIR, "") { - warning("The CLANG_DIR qmake variable is unset.") - warning("Add CLANG_DIR= to the qmake command-line.") - warning("The provided path should point to a" $$REQUIRED_CLANG_VERSION \ - "Clang installation.") - warning("(In the QtCreator IDE, add the setting in the Projects mode.)") - error("check-clang.pri: CLANG_DIR is unset. Aborting.") +# warning("The CLANG_DIR qmake variable is unset.") +# warning("Add CLANG_DIR= to the qmake command-line.") +# warning("The provided path should point to a" $$REQUIRED_CLANG_VERSION \ +# "Clang installation.") +# warning("(In the QtCreator IDE, add the setting in the Projects mode.)") +# error("check-clang.pri: CLANG_DIR is unset. Aborting.") } defineTest(checkClangRequire) { @@ -31,7 +31,7 @@ CLANG_LIBS = \ clangTooling clangParse clangSema clangAnalysis \ clangEdit clangAST clangLex clangBasic \ LLVMMC LLVMMCParser LLVMObject LLVMAsmParser LLVMCore LLVMProfileData LLVMSupport \ - LLVMOption LLVMBitWriter LLVMBitReader + LLVMOption LLVMBitWriter LLVMBitReader LLVMDemangle for(CLANG_LIB, CLANG_LIBS) { checkClangRequire($${CLANG_DIR}/lib/lib$${CLANG_LIB}.a) } diff --git a/clang-indexer/DaemonPool.cc b/clang-indexer/DaemonPool.cc index aaa2663..9859a26 100644 --- a/clang-indexer/DaemonPool.cc +++ b/clang-indexer/DaemonPool.cc @@ -13,7 +13,9 @@ namespace indexer { /////////////////////////////////////////////////////////////////////////////// // Daemon - +/** + * @brief Constructor of Daemon class + */ Daemon::Daemon() { std::string program = @@ -22,13 +24,23 @@ Daemon::Daemon() args.push_back("--daemon"); m_process = new Process(program, args); } - +/** + * @brief Destructor of Daemon class + */ Daemon::~Daemon() { fprintf(m_process->stdoutFile(), "\n"); delete m_process; } +/** + * @brief Function sends cmd arguments to child process by writing to stdin file child reads + * and then expects output from child process in stdout file, + * after reciving "DONE 0" from child, function destroys child process and exits + * @param workingDirectory + * @param args + * @return + */ int Daemon::run( const std::string &workingDirectory, const std::vector &args) @@ -61,16 +73,25 @@ int Daemon::run( /////////////////////////////////////////////////////////////////////////////// // DaemonPool +/** + * @brief DaemonPool::DaemonPool constructor + */ DaemonPool::DaemonPool() { } +/** + * @brief DaemonPool::~DaemonPool destructor + */ DaemonPool::~DaemonPool() { for (Daemon *daemon : m_daemons) delete daemon; } - +/** + * @brief If daemon list is empty create new daemon, else return last daemon inside list + * @return + */ Daemon *DaemonPool::get() { LockGuard lock(m_mutex); @@ -82,7 +103,10 @@ Daemon *DaemonPool::get() return new Daemon(); } } - +/** + * @brief Removes last daemon from list + * @param daemon + */ void DaemonPool::release(Daemon *daemon) { LockGuard lock(m_mutex); diff --git a/clang-indexer/IndexerContext.cc b/clang-indexer/IndexerContext.cc index 4ad07e2..6d511a2 100644 --- a/clang-indexer/IndexerContext.cc +++ b/clang-indexer/IndexerContext.cc @@ -158,7 +158,7 @@ IndexerFileContext &IndexerContext::fileContext(clang::FileID fileID) const clang::FileEntry *pFE = m_sourceManager.getFileEntryForID(fileID); if (pFE != NULL) { - char *filename = portableRealPath(pFE->getName()); + char *filename = portableRealPath(pFE->getName().data()); if (filename != NULL) { pathSymbolName += filename; free(filename); diff --git a/clang-indexer/IndexerPPCallbacks.cc b/clang-indexer/IndexerPPCallbacks.cc index 5508480..958ebb4 100644 --- a/clang-indexer/IndexerPPCallbacks.cc +++ b/clang-indexer/IndexerPPCallbacks.cc @@ -43,7 +43,7 @@ void IndexerPPCallbacks::InclusionDirective( auto it = m_includePathMap.find(file); if (it == m_includePathMap.end()) { std::string symbol = "@"; - char *path = portableRealPath(file->getName()); + char *path = portableRealPath(file->getName().data()); if (path != NULL) { symbol += path; free(path); diff --git a/clang-indexer/Mutex.cc b/clang-indexer/Mutex.cc index 9d24c58..8edeb99 100644 --- a/clang-indexer/Mutex.cc +++ b/clang-indexer/Mutex.cc @@ -1,9 +1,14 @@ #include "Mutex.h" #include - +/** + * @class Mutex + * @brief Does mutex locking of process on a shared resource, using criticalSection objects + */ namespace indexer { - +/** + * @brief Mutex::Mutex constructor + */ Mutex::Mutex() { #if INDEXER_MUTEX_USE_PTHREADS @@ -13,7 +18,9 @@ Mutex::Mutex() InitializeCriticalSection(&mutex); #endif } - +/** + * @brief Mutex::~Mutex destructor + */ Mutex::~Mutex() { #if INDEXER_MUTEX_USE_PTHREADS @@ -23,7 +30,9 @@ Mutex::~Mutex() DeleteCriticalSection(&mutex); #endif } - +/** + * @brief Locks the shared object + */ void Mutex::lock() { #if INDEXER_MUTEX_USE_PTHREADS @@ -37,7 +46,9 @@ void Mutex::lock() #error "Not implemented" #endif } - +/** + * @brief Unlocks the shared object + */ void Mutex::unlock() { #if INDEXER_MUTEX_USE_PTHREADS diff --git a/clang-indexer/NameGenerator.cc b/clang-indexer/NameGenerator.cc index 0db14b8..bcdd6fb 100644 --- a/clang-indexer/NameGenerator.cc +++ b/clang-indexer/NameGenerator.cc @@ -109,7 +109,7 @@ void NameGenerator::VisitDeclContext(clang::DeclContext *context) const clang::FileEntry *fileEntry = sourceManager.getFileEntryForID(fileID); if (fileEntry != NULL) { - m_out << const_basename(fileEntry->getName()); + m_out << const_basename(fileEntry->getName().data()); if (m_needOffsetPrefix) m_out << '@' << sourceManager.getFileOffset(sloc); m_out << '/'; diff --git a/clang-indexer/Process.cc b/clang-indexer/Process.cc index e086709..242219d 100644 --- a/clang-indexer/Process.cc +++ b/clang-indexer/Process.cc @@ -16,6 +16,10 @@ #if defined(_WIN32) #include #include +#include +#include +#include +#include #ifndef NOMINMAX #define NOMINMAX 1 #endif @@ -168,29 +172,53 @@ Process::Process( // seems to. CreateProcess seems to decide that the standard handles must // be inherited no matter what. BOOL success; - std::string cmdLine = makeCommandLine(programPath, args); + std::string cmdLine = makeCommandLine(programPath, args); + + +//child process handles + HANDLE hStdinRead = NULL; + HANDLE hStdinWrite = NULL; + HANDLE hStdoutRead = NULL; + HANDLE hStdoutWrite = NULL; + +// set the inheritHandle flag so pipe handles are inherited + SECURITY_ATTRIBUTES saAttr; + saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); + saAttr.bInheritHandle = TRUE; + saAttr.lpSecurityDescriptor = NULL; + + //create pipe for the child process STDOUT + success = CreatePipe(&hStdoutRead, &hStdoutWrite, &saAttr, 0); + assert(success); + // Ensure the read handle to the pipe for STDOUT is not inherited. + success = SetHandleInformation(hStdoutRead, HANDLE_FLAG_INHERIT, 0); + assert(success); + + //create pipe for the child process STDIN + success = CreatePipe(&hStdinRead, &hStdinWrite, &saAttr, 0); + assert(success); + // Ensure the write handle to the pipe for STDIN is not inherited. + success = SetHandleInformation(hStdinWrite, HANDLE_FLAG_INHERIT, 0); + assert(success); + +// create child process STARTUPINFOA sui; PROCESS_INFORMATION pi; + memset(&sui, 0, sizeof(sui)); memset(&pi, 0, sizeof(pi)); - sui.dwFlags = STARTF_USESTDHANDLES; - HANDLE hStdinRead; - HANDLE hStdinWrite; - HANDLE hStdoutRead; - HANDLE hStdoutWrite; - success = CreatePipe(&hStdinRead, &hStdinWrite, NULL, 0); - assert(success); - success = CreatePipe(&hStdoutRead, &hStdoutWrite, NULL, 0); - assert(success); + sui.cb = sizeof(sui); sui.hStdInput = hStdinRead; sui.hStdOutput = hStdoutWrite; - sui.hStdError = GetStdHandle(STD_ERROR_HANDLE); + sui.hStdError = hStdoutWrite; + sui.dwFlags |= STARTF_USESTDHANDLES; + BOOL ret = CreateProcessA( programPath.c_str(), &cmdLine[0], NULL, NULL, - /*bInheritHandles=*/FALSE, + /*bInheritHandles=*/TRUE, /*dwCreationFlags=*/0, /*lpEnvironment=*/NULL, /*lpCurrentDirectory=*/NULL, @@ -199,13 +227,13 @@ Process::Process( fprintf(stderr, "sw-clang-indexer: Error starting daemon process\n"); exit(1); } + m_p->hproc = pi.hProcess; CloseHandle(pi.hThread); CloseHandle(hStdinRead); CloseHandle(hStdoutWrite); - // Calling close() on these file descriptors will call CloseHandle(). - // (i.e. Ownership of the HANDLE is transferred. See the _open_osfhandle - // MSDN page.) + + //open files for stdin and stdout int stdinFd = _open_osfhandle(reinterpret_cast(hStdinWrite), _O_TEXT | _O_RDWR); int stdoutFd = _open_osfhandle(reinterpret_cast(hStdoutRead), diff --git a/clang-indexer/main.cc b/clang-indexer/main.cc index 34e3594..0ed4b8a 100644 --- a/clang-indexer/main.cc +++ b/clang-indexer/main.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -35,15 +36,24 @@ #include "IndexBuilder.h" #include "TUIndexer.h" #include "Util.h" +#include +#include namespace indexer { #define STRINGIFY(x) #x #define XSTRINGIFY(x) STRINGIFY(x) + // The Clang driver uses this driver path to locate its built-in include files // which are at ../lib/clang//include from the bin directory. -const char kDriverPath[] = XSTRINGIFY(INDEXER_CLANG_DIR) "/bin/clang"; +//QString tempDriverPath = QString(QUOTE(INDEXER_CLANG_DIR)); + +const char kDriverPath[] = "D:\\llvm\\mingwLLVMLibraries\\bin\\clang.exe"; + +/** + * @brief The SourceFileInfo struct used for storing info about source file being indexed + */ struct SourceFileInfo { std::string sourceFilePath; @@ -51,7 +61,28 @@ struct SourceFileInfo { std::string indexFilePath; std::vector clangArgv; }; - +/** + * @brief "Normalize" path found in command line to use native OS path separators + * @param cmdLine, returned from clang compilation database, + * @return std::vector + */ + +static std::vector normalizeCommandLinePaths(std::vector cmdLine){ + QString tempVar; + std::vector returnVector; + foreach(std::string command, cmdLine){ + tempVar = QString::fromStdString(command); +// tempVar = QDir::toNativeSeparators(tempVar); +// returnVector.push_back(tempVar.toStdString()); + returnVector.push_back(QDir::toNativeSeparators(tempVar).toStdString()); + } + return returnVector; +} +/** + * @brief Reads compile_commands.json file from working directory, and for each entry + * inside json it populates sourceFileInfo struct + * @return + */ static std::vector readSourcesJson() { std::vector ret; @@ -64,6 +95,10 @@ static std::vector readSourcesJson() << errmsg << std::endl; exit(1); } +//there is a bug in clang, CompilationDatabase->getAllCompileCommands() + //that can't escape backslashes, it should work with \\ which is generated inside + //compile_commands.json, but it only removes backslashes +// (workaround is to use forward slash / set manualy, or write some function that automates the process) for (const auto &command : compdb->getAllCompileCommands()) { // At the time of writing, at least, the libTooling CompilationDatabase @@ -78,22 +113,22 @@ static std::vector readSourcesJson() SourceFileInfo sfi; QDir workingDirectory(QString::fromStdString(command.Directory)); - sfi.workingDirectory = workingDirectory.absolutePath().toStdString(); + sfi.workingDirectory = QDir::toNativeSeparators(workingDirectory.absolutePath()).toStdString(); sfi.sourceFilePath = - QFileInfo(workingDirectory, + QDir::toNativeSeparators(QFileInfo(workingDirectory, QString::fromStdString( - command.Filename)).absoluteFilePath().toStdString(); - sfi.clangArgv = command.CommandLine; + command.Filename)).absoluteFilePath()).toStdString(); + sfi.clangArgv = normalizeCommandLinePaths(command.CommandLine); // Replace the first argument with the known Clang driver. if (sfi.clangArgv.size() >= 1) { // TODO: What if the argument is actually Clang, such as // /usr/bin/clang? Actually, can we get away with just using the // compiler in the JSON file? - bool isCXX = stringEndsWith(sfi.clangArgv[0], "++"); + bool isCXX = stringEndsWith(sfi.clangArgv[0], "++.exe"); sfi.clangArgv[0] = kDriverPath; if (isCXX) - sfi.clangArgv[0] += "++"; + sfi.clangArgv[0] += "++.exe"; } // Scan the argv looking for an -o argument specifying the output @@ -106,8 +141,8 @@ static std::vector readSourcesJson() QFileInfo objFile( workingDirectory, QString::fromStdString(sfi.clangArgv[i + 1])); - std::string filePath = - objFile.absoluteFilePath().toStdString(); + std::string filePath = QDir::toNativeSeparators( + objFile.absoluteFilePath()).toStdString(); filePath.erase(filePath.begin() + filePath.rfind('.'), filePath.end()); filePath += ".idx"; @@ -136,6 +171,12 @@ static std::vector readSourcesJson() return ret; } +/** + * @brief getCachedPathModTime + * @param fileTimeCache + * @param path + * @return + */ static time_t getCachedPathModTime( std::unordered_map &fileTimeCache, const std::string &path) @@ -150,8 +191,16 @@ static time_t getCachedPathModTime( } } + + // TODO: We need to save the (workingDirectory, clang-args) in the index file // somehow, so that if they change, we don't reuse the index. +/** + * @brief canReuseExistingIndexFile + * @param fileTimeCache + * @param sfi + * @return + */ static bool canReuseExistingIndexFile( std::unordered_map &fileTimeCache, const SourceFileInfo &sfi) @@ -172,7 +221,12 @@ static bool canReuseExistingIndexFile( } return true; } - +/** + * @brief indexProjectFile + * @param daemonPool + * @param sfi + * @return + */ static std::string indexProjectFile( DaemonPool *daemonPool, SourceFileInfo *sfi) @@ -196,7 +250,7 @@ static std::string indexProjectFile( Daemon *daemon = daemonPool->get(); std::vector args; args.push_back("--index-file"); - args.push_back(sfi->indexFilePath); + args.push_back(QDir::toNativeSeparators(QString::fromStdString(sfi->indexFilePath)).toStdString()); args.push_back("--"); args.insert(args.end(), sfi->clangArgv.begin(), sfi->clangArgv.end()); daemon->run(sfi->workingDirectory, args); @@ -285,7 +339,12 @@ void stripPCHIncludes(std::vector &sourceFiles) sfi.clangArgv = std::move(newClangArgv); } } - +/** + * @brief indexProject, indexes whole project, and creates index file inside working directory + * @param argv0 + * @param incremental + * @return + */ static int indexProject(const std::string &argv0, bool incremental) { std::vector sourceFiles = readSourcesJson(); @@ -351,7 +410,12 @@ static int indexProject(const std::string &argv0, bool incremental) return 0; } - +/** + * @brief indexFile, indexes separate project files (single translation units) + * @param outputFile + * @param clangArgv + * @return + */ static int indexFile( const std::string &outputFile, const std::vector &clangArgv) @@ -362,7 +426,11 @@ static int indexFile( archive.write(outputFile, /*compressed=*/true); return 0; } - +/** + * @brief Main driver function, resolves cmd line arguments passed to main and invokes apropriate jobs + * @param argv + * @return + */ static int runCommand(const std::vector &argv) { const char *const kUsageTextPattern = @@ -431,8 +499,20 @@ static int runCommand(const std::vector &argv) // static int runDaemon(const char *argv0) { +// //just a check +// HANDLE hStdin, hStdout; +// hStdout = GetStdHandle(STD_OUTPUT_HANDLE); +// hStdin = GetStdHandle(STD_INPUT_HANDLE); +// if ( +// (hStdout == INVALID_HANDLE_VALUE) || +// (hStdin == INVALID_HANDLE_VALUE) +// ) +// ExitProcess(1); + while (true) { + std::string cwd = readLine(stdin); + qDebug() << cwd.c_str(); if (cwd.empty()) return 0; std::vector commandArgv; @@ -462,7 +542,12 @@ static int runDaemon(const char *argv0) } } // namespace indexer - +/** + * @brief main + * @param argc + * @param argv + * @return + */ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); diff --git a/libindexdb/FileIo.cc b/libindexdb/FileIo.cc index 86ee50a..dfc95e0 100644 --- a/libindexdb/FileIo.cc +++ b/libindexdb/FileIo.cc @@ -68,7 +68,7 @@ Writer::Writer(const std::string &path) : m_sha256(NULL), m_compressed(false) int fd = EINTR_LOOP(open(pathPtr, flags, 0666)); m_fp = fdopen(fd, "w"); #else - m_fp = fopen(pathPtr, "w"); + m_fp = fopen(pathPtr, "wb"); #endif assert(m_fp != NULL); m_writeOffset = 0; @@ -351,6 +351,9 @@ void MappedReader::seek(uint64_t offset) char *MappedReader::readDataInternal(size_t size) { + //rekao bi da je slucajna vrednost koju procita, pa se pogubi sa ofsetom +// , nemoguce da dobije da je size=2573, + //TODO proveri mapiranje fajla size_t newOffset = m_offset + size; assert(newOffset >= m_offset && newOffset <= m_viewSize); size_t origOffset = m_offset; @@ -379,7 +382,7 @@ UnmappedReader::UnmappedReader(const std::string &path) int fd = EINTR_LOOP(open(pathPtr, O_RDONLY | O_CLOEXEC)); m_fp = fdopen(fd, "r"); #else - m_fp = fopen(pathPtr, "r"); + m_fp = fopen(pathPtr, "rb"); #endif assert(m_fp != NULL); Seek64(m_fp, 0, SEEK_END); diff --git a/libindexdb/IndexArchiveBuilder.h b/libindexdb/IndexArchiveBuilder.h index 7b6bffb..66bc821 100644 --- a/libindexdb/IndexArchiveBuilder.h +++ b/libindexdb/IndexArchiveBuilder.h @@ -15,7 +15,7 @@ class IndexArchiveBuilder void insert(const std::string &entryName, Index *index); Index *lookup(const std::string &entryName); void finalize(); - void write(const std::string &path, bool compressed=false); + void write(const std::string &path, bool compressed=true); private: std::map m_indices; diff --git a/link-clang.pri b/link-clang.pri index 16cab04..2ea594b 100644 --- a/link-clang.pri +++ b/link-clang.pri @@ -20,4 +20,4 @@ for(CLANG_LIB, CLANG_LIBS) { linux-*: LIBS += -ldl unix: LIBS += -lz -lncurses -win32: LIBS += -lpsapi -limagehlp -lpthread +win32: LIBS += -lpsapi -limagehlp -lpthread -luuid -lole32 -lversion diff --git a/navigator/File.h b/navigator/File.h index d49c3a0..9155ded 100644 --- a/navigator/File.h +++ b/navigator/File.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -61,7 +62,6 @@ class File : public FolderItem private: void loadFile(); - void ensureLoaded() { if (!m_loaded) loadFile(); diff --git a/navigator/FileManager.cc b/navigator/FileManager.cc index 5249a84..d87e58c 100644 --- a/navigator/FileManager.cc +++ b/navigator/FileManager.cc @@ -6,13 +6,21 @@ #include #include #include - +#include #include "File.h" #include "Folder.h" +#include -// XXX: Windows support +//TODO resolve different root paths on windows +#if defined(SOURCEWEB_UNIX) #define ROOT_PATH "/" #define PATH_SEP '/' +#elif defined(_WIN32) +#define ROOT_PATH "C:\\" +#define PATH_SEP '\\' +#endif +// XXX: Windows support + namespace Nav { @@ -23,6 +31,9 @@ FileManager::FileManager( const QString &projectRootPath, const QStringList &indexPaths) { + + //normalize project root path + QString normalizedProjectRootPath = QDir::toNativeSeparators(projectRootPath); m_categoryProject = new Folder(NULL, "", "Project"); m_categoryOutside = new Folder(NULL, "", "External"); m_categorySpecial = new Folder(NULL, "", "Special"); @@ -32,16 +43,27 @@ FileManager::FileManager( m_dirProject = new Folder( m_categoryProject, - QDir(projectRootPath).canonicalPath(), - QDir(projectRootPath).dirName()); + QDir::toNativeSeparators(QDir(normalizedProjectRootPath).canonicalPath()), + QDir(normalizedProjectRootPath).dirName()); m_allItems.append(m_dirProject); m_categoryProject->appendFolder(m_dirProject); - m_dirFilesystem = new Folder( - m_categoryOutside, - ROOT_PATH, // XXX: Won't work on Windows - ROOT_PATH); // XXX: Won't work on Windows - m_allItems.append(m_dirFilesystem); - m_categoryOutside->appendFolder(m_dirFilesystem); + //goes through each mounted drive on system, and adds its name to winRootPaths list, and creates Nav::Folder + //which is appended to m_categoryOutside, and then pointer is added to m_dirFilesystemRoots list + foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { + if (storage.isValid() && storage.isReady()) { + if (!storage.isReadOnly()) { + m_winRootPaths << QDir::toNativeSeparators(storage.displayName()); + + m_dirFilesystem = new Folder( + m_categoryOutside, + storage.displayName().mid(0,storage.displayName().length()-1), // XXX: Won't work on Windows + storage.displayName()); // XXX: Won't work on Windows + m_allItems.append(m_dirFilesystem); + m_categoryOutside->appendFolder(m_dirFilesystem); + m_dirFilesystemRoots.append(m_dirFilesystem); + } + } + } foreach (const QString &path, indexPaths) { file(path); @@ -68,16 +90,35 @@ FileManager::~FileManager() qDeleteAll(m_allItems); } +//support for windows paths added into this function +//This is a quick workaround, its far from perfect, but it does the decent job File &FileManager::file(const QString &path) { - if (path.startsWith("/")) { - QString projectPrefix = m_dirProject->path() + PATH_SEP; - if (path.startsWith(projectPrefix)) { - return file(m_dirProject, path.mid(projectPrefix.size())); + Nav::Folder *currentFolder; //pointer to folder file belongs + QString currentPath; //path to current file + bool specialFlag = false; //becomes true if current file belongs to special category + QString normalizedPath = QDir::toNativeSeparators(path); + int iterator = 0; //iterator for filesystemRoots pointer list + foreach (QString rootPath, m_winRootPaths) { + if (normalizedPath.startsWith("/") || normalizedPath.startsWith(rootPath) ) { + QString projectPrefix = QDir::toNativeSeparators(m_dirProject->path() + PATH_SEP); + if (normalizedPath.startsWith(projectPrefix)) { + currentFolder = m_dirProject; + currentPath = normalizedPath.mid(projectPrefix.size()); + specialFlag = false; + break; + } else { + currentFolder = m_dirFilesystemRoots.at(iterator); + currentPath = normalizedPath.mid(QString(rootPath).length()); + specialFlag = false; + break; + } } else { - return file(m_dirFilesystem, path.mid(1)); + specialFlag = true; } - } else { + iterator++; + } + if (specialFlag){ if (m_specialFiles.contains(path)) return *m_specialFiles[path]; File *result = new File(m_categorySpecial, path); @@ -86,6 +127,8 @@ File &FileManager::file(const QString &path) m_categorySpecial->appendFile(result); return *result; } + else + return file(currentFolder, currentPath); } File &FileManager::file(Folder *folder, const QString &relativePath) diff --git a/navigator/FileManager.h b/navigator/FileManager.h index 28d6bf2..9a17166 100644 --- a/navigator/FileManager.h +++ b/navigator/FileManager.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace Nav { @@ -34,7 +35,8 @@ class FileManager // The actual project and outside root folder. Folder *m_dirProject; Folder *m_dirFilesystem; - + QList m_dirFilesystemRoots; //stores pointers to created dirFileSystem folders + QStringList m_winRootPaths; //stores names of root folders QMap m_specialFiles; QList m_allItems; }; diff --git a/navigator/Project.cc b/navigator/Project.cc index b5e6d87..5f6dbf0 100644 --- a/navigator/Project.cc +++ b/navigator/Project.cc @@ -44,7 +44,6 @@ Project::Project(const QString &path) m_fileManager = new FileManager( QFileInfo(path).absolutePath(), queryAllPaths()); - // Start this query in the background. m_globalSymbolDefinitions = QtConcurrent::run(this, &Project::queryGlobalSymbolDefinitions); diff --git a/navigator/SourceWidget.cc b/navigator/SourceWidget.cc index 242ed21..5447e3e 100644 --- a/navigator/SourceWidget.cc +++ b/navigator/SourceWidget.cc @@ -632,7 +632,8 @@ void SourceWidgetView::paintLine( const int hovEndOff = m_hoverHighlightRange.end.toOffset(*m_file); const QBrush matchBrush(Qt::yellow); const QBrush selectedMatchBrush(QColor(255, 140, 0)); - const QBrush hoverBrush(QColor(200, 200, 200)); + const QBrush hoverBrush(QColor(255, 140, 0)); + const QBrush selectionReferenceBrush(QColor(255, 140, 0)); const int rightEdge = paintRegion.boundingRect().right() + 1; // Fill the line's background. @@ -650,7 +651,6 @@ void SourceWidgetView::paintLine( const int charFileIndex = lay.charFileIndex(); const QBrush *fillBrush = NULL; - // Find match background. for (; findMatch < m_findMatches.end(); ++findMatch) { if (findMatch->first > charFileIndex) @@ -669,7 +669,7 @@ void SourceWidgetView::paintLine( if (charFileIndex >= hovStartOff && charFileIndex < hovEndOff) fillBrush = &hoverBrush; if (charFileIndex >= selStartOff && charFileIndex < selEndOff) - fillBrush = &palette().highlight(); + fillBrush = &selectionReferenceBrush; if (fillBrush != NULL) { painter.fillRect(charBox.translated(-m_viewportOrigin), diff --git a/sourceweb.pro b/sourceweb.pro index 6a7d616..348ddbe 100644 --- a/sourceweb.pro +++ b/sourceweb.pro @@ -24,3 +24,4 @@ linux-*|freebsd-*|darwin-*|macx-* { } include(./check-clang.pri) + diff --git a/sourceweb.pro.user.55c384d b/sourceweb.pro.user.55c384d new file mode 100644 index 0000000..14180fd --- /dev/null +++ b/sourceweb.pro.user.55c384d @@ -0,0 +1,436 @@ + + + + + + EnvironmentId + {55c384dd-9a20-4a89-9167-b336ae779c65} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.8.0 MinGW 32bit + Desktop Qt 5.8.0 MinGW 32bit + qt.58.win32_mingw53_kit + 0 + 0 + 2 + + C:/Users/mikroe/Desktop/sourcewebBuild + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + CLANG_DIR="c:\\\\\\llvmDebugLibs" + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + CLANG_DIR=D:\llvm\llvm+clang Build\Debug + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + navigator + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/navigator/navigator.pro + true + index + navigator/navigator.pro + false + C:/Users/mikroe/Desktop/Clang-ast-viewer-master + C:/Users/mikroe/Desktop/sourcewebBuild/navigator + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + index-tool + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/index-tool/index-tool.pro + true + -- + index-tool/index-tool.pro + false + C:/Users/mikroe/Desktop/Clang-ast-viewer-master + C:/Users/mikroe/Desktop/sourcewebBuild/index-tool + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + clang-indexer + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/clang-indexer/clang-indexer.pro + true + --index-project + clang-indexer/clang-indexer.pro + false + C:/Users/mikroe/Desktop/Clang-ast-viewer-master + C:/Users/mikroe/Desktop/sourcewebBuild/clang-indexer + 3768 + false + true + false + false + true + + 3 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/sourceweb.pro.user.5f8c5cb b/sourceweb.pro.user.5f8c5cb new file mode 100644 index 0000000..3ed2a12 --- /dev/null +++ b/sourceweb.pro.user.5f8c5cb @@ -0,0 +1,436 @@ + + + + + + EnvironmentId + {5f8c5cb3-a071-491e-a964-8c59dd632251} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.8.0 MinGW 32bit + Desktop Qt 5.8.0 MinGW 32bit + qt.58.win32_mingw53_kit + 0 + 0 + 0 + + C:/Users/mikroe/Desktop/sourcewebBuild + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + CLANG_DIR=E:\Marko\LLVMdebug + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + CLANG_DIR=D:\llvm\llvm+clang Build\Debug + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + clang-indexer + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/clang-indexer/clang-indexer.pro + true + --index-project + clang-indexer/clang-indexer.pro + false + C:/Users/mikroe/Desktop/Clang-ast-viewer-master + C:/Users/mikroe/Desktop/sourcewebBuild/clang-indexer + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + index-tool + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/index-tool/index-tool.pro + true + + index-tool/index-tool.pro + false + + C:/Users/mikroe/Desktop/sourcewebBuild/index-tool + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + navigator + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/mikroe/Desktop/sourceweb-master/navigator/navigator.pro + true + index + navigator/navigator.pro + false + C:/Users/mikroe/Desktop/Clang-ast-viewer-master + C:/Users/mikroe/Desktop/sourcewebBuild/navigator + 3768 + false + true + false + false + true + + 3 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/sourceweb.pro.user.9657fae b/sourceweb.pro.user.9657fae new file mode 100644 index 0000000..902587e --- /dev/null +++ b/sourceweb.pro.user.9657fae @@ -0,0 +1,436 @@ + + + + + + EnvironmentId + {9657fae7-27de-4a95-a05f-65c3a62e1665} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.8.0 MinGW 32bit + Desktop Qt 5.8.0 MinGW 32bit + qt.58.win32_mingw53_kit + 0 + 0 + 1 + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + CLANG_DIR=D:\llvm\mingwLLVMLibraries + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + CLANG_DIR=D:\llvm\llvm+clang Build\Debug + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + clang-indexer + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Marko/Desktop/sourceweb-master/clang-indexer/clang-indexer.pro + true + --index-project + clang-indexer/clang-indexer.pro + false + C:/Users/Marko/Desktop/build-Clang-ast-viewer-master-Desktop_Qt_5_8_0_MinGW_32bit-Default + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Debug/clang-indexer + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + navigator + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Marko/Desktop/sourceweb-master/navigator/navigator.pro + true + index + navigator/navigator.pro + false + C:/Users/Marko/Desktop/build-Clang-ast-viewer-master-Desktop_Qt_5_8_0_MinGW_32bit-Default + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Debug/navigator + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + index-tool + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Marko/Desktop/sourceweb-master/index-tool/index-tool.pro + true + + index-tool/index-tool.pro + false + + C:/Users/Marko/Desktop/build-sourceweb-Desktop_Qt_5_8_0_MinGW_32bit-Debug/index-tool + 3768 + false + true + false + false + true + + 3 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + +