diff options
-rw-r--r-- | plugins/haskell/filecache.cpp | 14 | ||||
-rw-r--r-- | plugins/haskell/filecache.h | 8 | ||||
-rw-r--r-- | plugins/haskell/followsymbol.cpp | 4 | ||||
-rw-r--r-- | plugins/haskell/followsymbol.h | 4 | ||||
-rw-r--r-- | plugins/haskell/ghcmod.cpp | 38 | ||||
-rw-r--r-- | plugins/haskell/ghcmod.h | 32 | ||||
-rw-r--r-- | plugins/haskell/haskellbuildconfiguration.cpp | 6 | ||||
-rw-r--r-- | plugins/haskell/haskelldocument.cpp | 2 | ||||
-rw-r--r-- | plugins/haskell/haskellhoverhandler.h | 2 | ||||
-rw-r--r-- | plugins/haskell/haskellmanager.cpp | 28 | ||||
-rw-r--r-- | plugins/haskell/haskellmanager.h | 10 | ||||
-rw-r--r-- | plugins/haskell/haskellproject.cpp | 26 | ||||
-rw-r--r-- | plugins/haskell/haskellproject.h | 4 | ||||
-rw-r--r-- | plugins/haskell/haskellrunconfiguration.cpp | 9 | ||||
-rw-r--r-- | plugins/haskell/haskellrunconfiguration.h | 30 | ||||
-rw-r--r-- | plugins/haskell/stackbuildstep.cpp | 8 |
16 files changed, 114 insertions, 111 deletions
diff --git a/plugins/haskell/filecache.cpp b/plugins/haskell/filecache.cpp index 55ee552..5d931c9 100644 --- a/plugins/haskell/filecache.cpp +++ b/plugins/haskell/filecache.cpp @@ -56,7 +56,7 @@ void FileCache::update() { const QList<IDocument *> documents = m_documentsToUpdate(); for (IDocument *document : documents) { - const Utils::FileName filePath = document->filePath(); + const Utils::FilePath filePath = document->filePath(); if (m_fileMap.contains(filePath)) { // update the existing cached file // check revision if possible @@ -75,14 +75,14 @@ void FileCache::update() cleanUp(documents); } -QHash<FileName, FileName> FileCache::fileMap() const +QHash<FilePath, FilePath> FileCache::fileMap() const { return m_fileMap; } void FileCache::writeFile(IDocument *document) { - FileName cacheFilePath = m_fileMap.value(document->filePath()); + FilePath cacheFilePath = m_fileMap.value(document->filePath()); if (cacheFilePath.isEmpty()) { cacheFilePath = createCacheFile(document->filePath()); m_fileMap.insert(document->filePath(), cacheFilePath); @@ -114,8 +114,8 @@ void FileCache::writeFile(IDocument *document) void FileCache::cleanUp(const QList<IDocument *> &documents) { - const QSet<FileName> files = Utils::transform<QSet>(documents, &IDocument::filePath); - auto it = QMutableHashIterator<FileName, FileName>(m_fileMap); + const QSet<FilePath> files = Utils::transform<QSet>(documents, &IDocument::filePath); + auto it = QMutableHashIterator<FilePath, FilePath>(m_fileMap); while (it.hasNext()) { it.next(); if (!files.contains(it.key())) { @@ -127,12 +127,12 @@ void FileCache::cleanUp(const QList<IDocument *> &documents) } } -FileName FileCache::createCacheFile(const FileName &filePath) +FilePath FileCache::createCacheFile(const FilePath &filePath) { QTemporaryFile tempFile(m_tempDir.path() + "/XXXXXX-" + filePath.fileName()); tempFile.setAutoRemove(false); tempFile.open(); - return FileName::fromString(tempFile.fileName()); + return FilePath::fromString(tempFile.fileName()); } } // namespace Internal diff --git a/plugins/haskell/filecache.h b/plugins/haskell/filecache.h index 46c48ab..3c53d40 100644 --- a/plugins/haskell/filecache.h +++ b/plugins/haskell/filecache.h @@ -44,16 +44,16 @@ public: const std::function<QList<Core::IDocument *>()> &documentsToUpdate); void update(); - QHash<Utils::FileName, Utils::FileName> fileMap() const; + QHash<Utils::FilePath, Utils::FilePath> fileMap() const; private: void writeFile(Core::IDocument *document); void cleanUp(const QList<Core::IDocument *> &documents); - Utils::FileName createCacheFile(const Utils::FileName &filePath); + Utils::FilePath createCacheFile(const Utils::FilePath &filePath); Utils::TemporaryDirectory m_tempDir; - QHash<Utils::FileName, Utils::FileName> m_fileMap; - QHash<Utils::FileName, int> m_fileRevision; + QHash<Utils::FilePath, Utils::FilePath> m_fileMap; + QHash<Utils::FilePath, int> m_fileRevision; std::function<QList<Core::IDocument *>()> m_documentsToUpdate; }; diff --git a/plugins/haskell/followsymbol.cpp b/plugins/haskell/followsymbol.cpp index d75c680..ab32614 100644 --- a/plugins/haskell/followsymbol.cpp +++ b/plugins/haskell/followsymbol.cpp @@ -70,7 +70,7 @@ IAssistProposal *FollowSymbolAssistProcessor::immediateProposal(const AssistInte = HaskellEditorWidget::symbolAt(interface->textDocument(), interface->position(), &line, &column); QTC_ASSERT(symbol, return nullptr); // should have been checked before - const auto filePath = FileName::fromString(interface->fileName()); + const auto filePath = FilePath::fromString(interface->fileName()); m_ghcmod = HaskellManager::ghcModForFile(filePath); m_symbolFuture = m_ghcmod->findSymbol(filePath, symbol->text.toString()); @@ -94,7 +94,7 @@ IAssistProposal *FollowSymbolAssistProcessor::perform(const AssistInterface *int return new InstantProposal(position, {item}); } -FollowSymbolAssistProposalItem::FollowSymbolAssistProposalItem(const FileName &basePath, +FollowSymbolAssistProposalItem::FollowSymbolAssistProposalItem(const FilePath &basePath, const SymbolInfoOrError &info, bool inNextSplit) : m_basePath(basePath), diff --git a/plugins/haskell/followsymbol.h b/plugins/haskell/followsymbol.h index 63ad772..a4f9051 100644 --- a/plugins/haskell/followsymbol.h +++ b/plugins/haskell/followsymbol.h @@ -39,14 +39,14 @@ namespace Internal { class FollowSymbolAssistProposalItem : public TextEditor::AssistProposalItem { public: - FollowSymbolAssistProposalItem(const Utils::FileName &basePath, + FollowSymbolAssistProposalItem(const Utils::FilePath &basePath, const SymbolInfoOrError &info, bool inNextSplit); void apply(TextEditor::TextDocumentManipulatorInterface &, int) const override; private: - Utils::FileName m_basePath; + Utils::FilePath m_basePath; SymbolInfoOrError m_info; bool m_inNextSplit; }; diff --git a/plugins/haskell/ghcmod.cpp b/plugins/haskell/ghcmod.cpp index e110230..1ca7713 100644 --- a/plugins/haskell/ghcmod.cpp +++ b/plugins/haskell/ghcmod.cpp @@ -54,10 +54,10 @@ using namespace Utils; namespace Haskell { namespace Internal { -FileName GhcMod::m_stackExecutable = Utils::FileName::fromString("stack"); +FilePath GhcMod::m_stackExecutable = Utils::FilePath::fromString("stack"); QMutex GhcMod::m_mutex; -GhcMod::GhcMod(const Utils::FileName &path) +GhcMod::GhcMod(const Utils::FilePath &path) : m_path(path) { } @@ -67,12 +67,12 @@ GhcMod::~GhcMod() shutdown(); } -FileName GhcMod::basePath() const +FilePath GhcMod::basePath() const { return m_path; } -void GhcMod::setFileMap(const QHash<FileName, FileName> &fileMap) +void GhcMod::setFileMap(const QHash<FilePath, FilePath> &fileMap) { if (fileMap != m_fileMap) { log("setting new file map"); @@ -88,17 +88,17 @@ static QString toUnicode(QByteArray data) return QString::fromUtf8(data); } -SymbolInfoOrError GhcMod::findSymbol(const FileName &filePath, const QString &symbol) +SymbolInfoOrError GhcMod::findSymbol(const FilePath &filePath, const QString &symbol) { return parseFindSymbol(runFindSymbol(filePath, symbol)); } -QStringOrError GhcMod::typeInfo(const FileName &filePath, int line, int col) +QStringOrError GhcMod::typeInfo(const FilePath &filePath, int line, int col) { return parseTypeInfo(runTypeInfo(filePath, line, col)); } -static QStringList fileMapArgs(const QHash<FileName, FileName> &map) +static QStringList fileMapArgs(const QHash<FilePath, FilePath> &map) { QStringList result; const auto end = map.cend(); @@ -110,15 +110,15 @@ static QStringList fileMapArgs(const QHash<FileName, FileName> &map) Utils::optional<Error> GhcMod::ensureStarted() { m_mutex.lock(); - const FileName plainStackExecutable = m_stackExecutable; + const FilePath plainStackExecutable = m_stackExecutable; m_mutex.unlock(); Environment env = Environment::systemEnvironment(); - const FileName stackExecutable = env.searchInPath(plainStackExecutable.toString()); + const FilePath stackExecutable = env.searchInPath(plainStackExecutable.toString()); if (m_process) { if (m_process->state() == QProcess::NotRunning) { log("is no longer running"); m_process.reset(); - } else if (FileName::fromString(m_process->program()) != stackExecutable) { + } else if (FilePath::fromString(m_process->program()) != stackExecutable) { log("stack settings changed"); shutdown(); } @@ -190,13 +190,13 @@ QByteArrayOrError GhcMod::runQuery(const QString &query) return response; } -QByteArrayOrError GhcMod::runFindSymbol(const FileName &filePath, const QString &symbol) +QByteArrayOrError GhcMod::runFindSymbol(const FilePath &filePath, const QString &symbol) { return runQuery(QString("info %1 %2").arg(filePath.toString()) // TODO toNative? quoting? .arg(symbol)); } -QByteArrayOrError GhcMod::runTypeInfo(const FileName &filePath, int line, int col) +QByteArrayOrError GhcMod::runTypeInfo(const FilePath &filePath, int line, int col) { return runQuery(QString("type %1 %2 %3").arg(filePath.toString()) // TODO toNative? quoting? .arg(line) @@ -221,7 +221,7 @@ SymbolInfoOrError GhcMod::parseFindSymbol(const QByteArrayOrError &response) hasFileOrModule = true; info.definition += result.captured(1); if (result.lastCapturedIndex() == 7) { // Defined at <file:line:col> - info.file = FileName::fromString(result.captured(4)); + info.file = FilePath::fromString(result.captured(4)); bool ok; int num = result.captured(6).toInt(&ok); if (ok) @@ -255,20 +255,20 @@ QStringOrError GhcMod::parseTypeInfo(const QByteArrayOrError &response) return Error({Error::Type::Other, QString()}); } -void GhcMod::setStackExecutable(const FileName &filePath) +void GhcMod::setStackExecutable(const FilePath &filePath) { QMutexLocker lock(&m_mutex); m_stackExecutable = filePath; } -static QList<Core::IDocument *> getOpenDocuments(const FileName &path) +static QList<Core::IDocument *> getOpenDocuments(const FilePath &path) { return Utils::filtered(Core::DocumentModel::openedDocuments(), [path] (Core::IDocument *doc) { return path.isEmpty() || doc->filePath().isChildOf(path); }); } -AsyncGhcMod::AsyncGhcMod(const FileName &path) +AsyncGhcMod::AsyncGhcMod(const FilePath &path) : m_ghcmod(path), m_fileCache("haskell", std::bind(getOpenDocuments, path)) { @@ -289,7 +289,7 @@ AsyncGhcMod::~AsyncGhcMod() m_thread.wait(); } -FileName AsyncGhcMod::basePath() const +FilePath AsyncGhcMod::basePath() const { return m_ghcmod.basePath(); } @@ -330,7 +330,7 @@ QFuture<Result> createFuture(AsyncGhcMod::Operation op, Returns a QFuture handle for the asynchronous operation. You may not block the main event loop while waiting for it to finish - doing so will result in a deadlock. */ -QFuture<SymbolInfoOrError> AsyncGhcMod::findSymbol(const FileName &filePath, +QFuture<SymbolInfoOrError> AsyncGhcMod::findSymbol(const FilePath &filePath, const QString &symbol) { QMutexLocker lock(&m_mutex); @@ -346,7 +346,7 @@ QFuture<SymbolInfoOrError> AsyncGhcMod::findSymbol(const FileName &filePath, Returns a QFuture handle for the asynchronous operation. You may not block the main event loop while waiting for it to finish - doing so will result in a deadlock. */ -QFuture<QStringOrError> AsyncGhcMod::typeInfo(const FileName &filePath, int line, int col) +QFuture<QStringOrError> AsyncGhcMod::typeInfo(const FilePath &filePath, int line, int col) { QMutexLocker lock(&m_mutex); Operation op([this, filePath, line, col] { return m_ghcmod.runTypeInfo(filePath, line, col); }); diff --git a/plugins/haskell/ghcmod.h b/plugins/haskell/ghcmod.h index 978b58e..fb3dd3f 100644 --- a/plugins/haskell/ghcmod.h +++ b/plugins/haskell/ghcmod.h @@ -59,7 +59,7 @@ class SymbolInfo { public: QStringList definition; QStringList additionalInfo; - Utils::FileName file; + Utils::FilePath file; int line = -1; int col = -1; QString module; @@ -80,36 +80,36 @@ using unique_ghcmod_process = std::unique_ptr<QProcess, ghcmod_deleter<QProcess> class GhcMod { public: - GhcMod(const Utils::FileName &path); + GhcMod(const Utils::FilePath &path); ~GhcMod(); - Utils::FileName basePath() const; - void setFileMap(const QHash<Utils::FileName, Utils::FileName> &fileMap); + Utils::FilePath basePath() const; + void setFileMap(const QHash<Utils::FilePath, Utils::FilePath> &fileMap); - SymbolInfoOrError findSymbol(const Utils::FileName &filePath, const QString &symbol); - QStringOrError typeInfo(const Utils::FileName &filePath, int line, int col); + SymbolInfoOrError findSymbol(const Utils::FilePath &filePath, const QString &symbol); + QStringOrError typeInfo(const Utils::FilePath &filePath, int line, int col); QByteArrayOrError runQuery(const QString &query); - QByteArrayOrError runFindSymbol(const Utils::FileName &filePath, const QString &symbol); - QByteArrayOrError runTypeInfo(const Utils::FileName &filePath, int line, int col); + QByteArrayOrError runFindSymbol(const Utils::FilePath &filePath, const QString &symbol); + QByteArrayOrError runTypeInfo(const Utils::FilePath &filePath, int line, int col); static SymbolInfoOrError parseFindSymbol(const QByteArrayOrError &response); static QStringOrError parseTypeInfo(const QByteArrayOrError &response); - static void setStackExecutable(const Utils::FileName &filePath); + static void setStackExecutable(const Utils::FilePath &filePath); private: Utils::optional<Error> ensureStarted(); void shutdown(); void log(const QString &message); - static Utils::FileName m_stackExecutable; + static Utils::FilePath m_stackExecutable; static QMutex m_mutex; - Utils::FileName m_path; + Utils::FilePath m_path; unique_ghcmod_process m_process; // kills process on reset - QHash<Utils::FileName, Utils::FileName> m_fileMap; + QHash<Utils::FilePath, Utils::FilePath> m_fileMap; }; class AsyncGhcMod : public QObject @@ -124,13 +124,13 @@ public: std::function<QByteArrayOrError()> op; }; - AsyncGhcMod(const Utils::FileName &path); + AsyncGhcMod(const Utils::FilePath &path); ~AsyncGhcMod(); - Utils::FileName basePath() const; + Utils::FilePath basePath() const; - QFuture<SymbolInfoOrError> findSymbol(const Utils::FileName &filePath, const QString &symbol); - QFuture<QStringOrError> typeInfo(const Utils::FileName &filePath, int line, int col); + QFuture<SymbolInfoOrError> findSymbol(const Utils::FilePath &filePath, const QString &symbol); + QFuture<QStringOrError> typeInfo(const Utils::FilePath &filePath, int line, int col); private slots: void updateCache(); // called through QMetaObject::invokeMethod diff --git a/plugins/haskell/haskellbuildconfiguration.cpp b/plugins/haskell/haskellbuildconfiguration.cpp index b09c7b4..0233e15 100644 --- a/plugins/haskell/haskellbuildconfiguration.cpp +++ b/plugins/haskell/haskellbuildconfiguration.cpp @@ -60,12 +60,12 @@ HaskellBuildConfigurationFactory::HaskellBuildConfigurationFactory() static QList<BuildInfo> createInfos(const HaskellBuildConfigurationFactory *factory, const Kit *k, - const Utils::FileName &projectFilePath) + const Utils::FilePath &projectFilePath) { BuildInfo info(factory); info.typeName = HaskellBuildConfigurationFactory::tr("Release"); info.displayName = info.typeName; - info.buildDirectory = projectFilePath.parentDir().appendPath(".stack-work"); + info.buildDirectory = projectFilePath.parentDir().pathAppended(".stack-work"); info.kitId = k->id(); info.buildType = BuildConfiguration::BuildType::Release; return {info}; @@ -84,7 +84,7 @@ QList<BuildInfo> HaskellBuildConfigurationFactory::availableBuilds(const Target QList<BuildInfo> HaskellBuildConfigurationFactory::availableSetups( const Kit *k, const QString &projectPath) const { - return createInfos(this, k, Utils::FileName::fromString(projectPath)); + return createInfos(this, k, Utils::FilePath::fromString(projectPath)); } HaskellBuildConfiguration::HaskellBuildConfiguration(Target *target, Core::Id id) diff --git a/plugins/haskell/haskelldocument.cpp b/plugins/haskell/haskelldocument.cpp index 98850bc..b2cc8e0 100644 --- a/plugins/haskell/haskelldocument.cpp +++ b/plugins/haskell/haskelldocument.cpp @@ -37,7 +37,7 @@ namespace Internal { HaskellDocument::HaskellDocument() : TextDocument(Constants::C_HASKELLEDITOR_ID) { - connect(this, &IDocument::filePathChanged, this, [this](const FileName &, const FileName &fn) { + connect(this, &IDocument::filePathChanged, this, [this](const FilePath &, const FilePath &fn) { m_ghcmod = HaskellManager::ghcModForFile(fn); }); } diff --git a/plugins/haskell/haskellhoverhandler.h b/plugins/haskell/haskellhoverhandler.h index ab200a1..a85da8e 100644 --- a/plugins/haskell/haskellhoverhandler.h +++ b/plugins/haskell/haskellhoverhandler.h @@ -44,7 +44,7 @@ private: void cancel(); - Utils::FileName m_filePath; + Utils::FilePath m_filePath; int m_line = -1; int m_col = -1; QString m_name; diff --git a/plugins/haskell/haskellmanager.cpp b/plugins/haskell/haskellmanager.cpp index a0ab153..a2eadc6 100644 --- a/plugins/haskell/haskellmanager.cpp +++ b/plugins/haskell/haskellmanager.cpp @@ -46,8 +46,8 @@ namespace Internal { class HaskellManagerPrivate { public: - std::unordered_map<FileName, std::weak_ptr<AsyncGhcMod>> ghcModCache; - FileName stackExecutable; + std::unordered_map<FilePath, std::weak_ptr<AsyncGhcMod>> ghcModCache; + FilePath stackExecutable; }; Q_GLOBAL_STATIC(HaskellManagerPrivate, m_d) @@ -58,10 +58,10 @@ HaskellManager *HaskellManager::instance() return m_instance; } -FileName HaskellManager::findProjectDirectory(const FileName &filePath) +FilePath HaskellManager::findProjectDirectory(const FilePath &filePath) { if (filePath.isEmpty()) - return FileName(); + return {}; QDir directory(filePath.toFileInfo().isDir() ? filePath.toString() : filePath.parentDir().toString()); @@ -69,14 +69,14 @@ FileName HaskellManager::findProjectDirectory(const FileName &filePath) directory.setFilter(QDir::Files | QDir::Readable); do { if (!directory.entryList().isEmpty()) - return FileName::fromString(directory.path()); + return FilePath::fromString(directory.path()); } while (!directory.isRoot() && directory.cdUp()); - return FileName(); + return {}; } -std::shared_ptr<AsyncGhcMod> HaskellManager::ghcModForFile(const FileName &filePath) +std::shared_ptr<AsyncGhcMod> HaskellManager::ghcModForFile(const FilePath &filePath) { - const FileName projectPath = findProjectDirectory(filePath); + const FilePath projectPath = findProjectDirectory(filePath); const auto cacheEntry = m_d->ghcModCache.find(projectPath); if (cacheEntry != m_d->ghcModCache.cend()) { if (cacheEntry->second.expired()) @@ -89,21 +89,21 @@ std::shared_ptr<AsyncGhcMod> HaskellManager::ghcModForFile(const FileName &fileP return ghcmod; } -FileName defaultStackExecutable() +FilePath defaultStackExecutable() { // stack from brew or the installer script from https://docs.haskellstack.org // install to /usr/local/bin. if (HostOsInfo::isAnyUnixHost()) - return FileName::fromString("/usr/local/bin/stack"); - return FileName::fromString("stack"); + return FilePath::fromString("/usr/local/bin/stack"); + return FilePath::fromString("stack"); } -FileName HaskellManager::stackExecutable() +FilePath HaskellManager::stackExecutable() { return m_d->stackExecutable; } -void HaskellManager::setStackExecutable(const FileName &filePath) +void HaskellManager::setStackExecutable(const FilePath &filePath) { if (filePath == m_d->stackExecutable) return; @@ -113,7 +113,7 @@ void HaskellManager::setStackExecutable(const FileName &filePath) void HaskellManager::readSettings(QSettings *settings) { - m_d->stackExecutable = FileName::fromString( + m_d->stackExecutable = FilePath::fromString( settings->value(kStackExecutableKey, defaultStackExecutable().toString()).toString()); emit m_instance->stackExecutableChanged(m_d->stackExecutable); diff --git a/plugins/haskell/haskellmanager.h b/plugins/haskell/haskellmanager.h index aea4106..b4a2e35 100644 --- a/plugins/haskell/haskellmanager.h +++ b/plugins/haskell/haskellmanager.h @@ -45,17 +45,17 @@ class HaskellManager : public QObject public: static HaskellManager *instance(); - static Utils::FileName findProjectDirectory(const Utils::FileName &filePath); - static std::shared_ptr<AsyncGhcMod> ghcModForFile(const Utils::FileName &filePath); - static Utils::FileName stackExecutable(); - static void setStackExecutable(const Utils::FileName &filePath); + static Utils::FilePath findProjectDirectory(const Utils::FilePath &filePath); + static std::shared_ptr<AsyncGhcMod> ghcModForFile(const Utils::FilePath &filePath); + static Utils::FilePath stackExecutable(); + static void setStackExecutable(const Utils::FilePath &filePath); static void readSettings(QSettings *settings); static void writeSettings(QSettings *settings); static QString trLookingUp(const QString &name); signals: - void stackExecutableChanged(const Utils::FileName &filePath); + void stackExecutableChanged(const Utils::FilePath &filePath); }; } // namespace Internal diff --git a/plugins/haskell/haskellproject.cpp b/plugins/haskell/haskellproject.cpp index bdc3860..92b30e6 100644 --- a/plugins/haskell/haskellproject.cpp +++ b/plugins/haskell/haskellproject.cpp @@ -47,7 +47,7 @@ using namespace Utils; namespace Haskell { namespace Internal { -static QVector<QString> parseExecutableNames(const FileName &projectFilePath) +static QVector<QString> parseExecutableNames(const FilePath &projectFilePath) { static const QString EXECUTABLE = "executable"; static const int EXECUTABLE_LEN = EXECUTABLE.length(); @@ -65,11 +65,11 @@ static QVector<QString> parseExecutableNames(const FileName &projectFilePath) return result; } -HaskellProjectNode::HaskellProjectNode(const FileName &projectFilePath, Core::Id id) - : ProjectNode(projectFilePath, id.toString().toLatin1()) +HaskellProjectNode::HaskellProjectNode(const FilePath &projectFilePath) + : ProjectNode(projectFilePath) {} -HaskellProject::HaskellProject(const Utils::FileName &fileName) +HaskellProject::HaskellProject(const Utils::FilePath &fileName) : Project(Constants::C_HASKELL_PROJECT_MIMETYPE, fileName, [this] { refresh(); }) { setId(Constants::C_HASKELL_PROJECT_ID); @@ -86,17 +86,17 @@ bool HaskellProject::isHaskellProject(Project *project) void HaskellProject::updateFiles() { emitParsingStarted(); - FileName projectDir = projectDirectory(); + FilePath projectDir = projectDirectory(); QFuture<QList<FileNode *>> future = Utils::runAsync([this, projectDir] { - return FileNode::scanForFiles(projectDir, [this](const FileName &fn) -> FileNode * { - if (fn != FileName::fromString(projectFilePath().toString() + ".user")) - return new FileNode(fn, FileType::Source, false); + return FileNode::scanForFiles(projectDir, [this](const FilePath &fn) -> FileNode * { + if (fn != FilePath::fromString(projectFilePath().toString() + ".user")) + return new FileNode(fn, FileType::Source); else return nullptr; }); }); Utils::onResultReady(future, this, [this](const QList<FileNode *> &nodes) { - auto root = new HaskellProjectNode(projectDirectory(), id()); + auto root = new HaskellProjectNode(projectDirectory()); root->setDisplayName(displayName()); std::vector<std::unique_ptr<FileNode>> nodePtrs = Utils::transform<std::vector>(nodes, [](FileNode *fn) { @@ -112,20 +112,18 @@ void HaskellProject::updateApplicationTargets(Target *target) { QTC_ASSERT(target, return); const QVector<QString> executables = parseExecutableNames(projectFilePath()); - const Utils::FileName projFilePath = projectFilePath(); + const Utils::FilePath projFilePath = projectFilePath(); const QList<BuildTargetInfo> appTargets = Utils::transform<QList>(executables, [projFilePath](const QString &executable) { BuildTargetInfo bti; bti.displayName = executable; bti.buildKey = executable; - bti.targetFilePath = FileName::fromString(executable); + bti.targetFilePath = FilePath::fromString(executable); bti.projectFilePath = projFilePath; bti.isQtcRunnable = true; return bti; }); - BuildTargetInfoList list; - list.list = appTargets; - target->setApplicationTargets(list); + target->setApplicationTargets(appTargets); target->updateDefaultRunConfigurations(); } diff --git a/plugins/haskell/haskellproject.h b/plugins/haskell/haskellproject.h index 0c307e7..0afb717 100644 --- a/plugins/haskell/haskellproject.h +++ b/plugins/haskell/haskellproject.h @@ -34,7 +34,7 @@ namespace Internal { class HaskellProjectNode : public ProjectExplorer::ProjectNode { public: - HaskellProjectNode(const Utils::FileName &projectFilePath, Core::Id id); + HaskellProjectNode(const Utils::FilePath &projectFilePath); }; class HaskellProject : public ProjectExplorer::Project @@ -42,7 +42,7 @@ class HaskellProject : public ProjectExplorer::Project Q_OBJECT public: - explicit HaskellProject(const Utils::FileName &fileName); + explicit HaskellProject(const Utils::FilePath &fileName); static bool isHaskellProject(Project *project); diff --git a/plugins/haskell/haskellrunconfiguration.cpp b/plugins/haskell/haskellrunconfiguration.cpp index ffdcb6d..78ea231 100644 --- a/plugins/haskell/haskellrunconfiguration.cpp +++ b/plugins/haskell/haskellrunconfiguration.cpp @@ -33,6 +33,7 @@ #include <projectexplorer/localenvironmentaspect.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/runconfigurationaspects.h> +#include <projectexplorer/runcontrol.h> #include <projectexplorer/target.h> using namespace ProjectExplorer; @@ -45,7 +46,6 @@ HaskellRunConfigurationFactory::HaskellRunConfigurationFactory() registerRunConfiguration<HaskellRunConfiguration>("Haskell.RunConfiguration"); addSupportedProjectType(Constants::C_HASKELL_PROJECT_ID); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); - addRunWorkerFactory<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE); } HaskellExecutableAspect::HaskellExecutableAspect() @@ -57,18 +57,17 @@ HaskellExecutableAspect::HaskellExecutableAspect() HaskellRunConfiguration::HaskellRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto envAspect = addAspect<LocalEnvironmentAspect> - (target, LocalEnvironmentAspect::BaseEnvironmentModifier()); + addAspect<LocalEnvironmentAspect>(target); auto executableAspect = addAspect<HaskellExecutableAspect>(); connect(target, &Target::applicationTargetsChanged, this, [this, target, executableAspect] { - BuildTargetInfo bti = target->applicationTargets().buildTargetInfo(buildKey()); + BuildTargetInfo bti = target->buildTarget(buildKey()); executableAspect->setValue(bti.targetFilePath.toString()); }); addAspect<ArgumentsAspect>(); - auto workingDirAspect = addAspect<WorkingDirectoryAspect>(envAspect); + auto workingDirAspect = addAspect<WorkingDirectoryAspect>(); workingDirAspect->setDefaultWorkingDirectory(target->project()->projectDirectory()); workingDirAspect->setVisible(false); diff --git a/plugins/haskell/haskellrunconfiguration.h b/plugins/haskell/haskellrunconfiguration.h index 578fc72..62bbd3d 100644 --- a/plugins/haskell/haskellrunconfiguration.h +++ b/plugins/haskell/haskellrunconfiguration.h @@ -26,34 +26,40 @@ #pragma once #include <projectexplorer/runconfigurationaspects.h> +#include <projectexplorer/runcontrol.h> namespace Haskell { namespace Internal { -class HaskellRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory +class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration { + Q_OBJECT + public: - HaskellRunConfigurationFactory(); + HaskellRunConfiguration(ProjectExplorer::Target *target, Core::Id id); + +private: + void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &info) final; + ProjectExplorer::Runnable runnable() const final; }; -class HaskellExecutableAspect : public ProjectExplorer::BaseStringAspect +class HaskellRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory { - Q_OBJECT - public: - HaskellExecutableAspect(); + HaskellRunConfigurationFactory(); + +private: + ProjectExplorer::SimpleRunWorkerFactory<ProjectExplorer::SimpleTargetRunner, + HaskellRunConfiguration> + runWorkerFactory; }; -class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration +class HaskellExecutableAspect : public ProjectExplorer::BaseStringAspect { Q_OBJECT public: - HaskellRunConfiguration(ProjectExplorer::Target *target, Core::Id id); - -private: - void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &info) final; - ProjectExplorer::Runnable runnable() const final; + HaskellExecutableAspect(); }; } // namespace Internal diff --git a/plugins/haskell/stackbuildstep.cpp b/plugins/haskell/stackbuildstep.cpp index 7dc7f6a..931fa32 100644 --- a/plugins/haskell/stackbuildstep.cpp +++ b/plugins/haskell/stackbuildstep.cpp @@ -53,15 +53,15 @@ StackBuildStep::StackBuildStep(ProjectExplorer::BuildStepList *bsl) const auto updateEnvironment = [this] { processParameters()->setEnvironment(buildConfiguration()->environment()); }; - processParameters()->setCommand(HaskellManager::stackExecutable().toString()); + processParameters()->setCommand(HaskellManager::stackExecutable()); updateArguments(); - processParameters()->setWorkingDirectory(project()->projectDirectory().toString()); + processParameters()->setWorkingDirectory(project()->projectDirectory()); updateEnvironment(); connect(HaskellManager::instance(), &HaskellManager::stackExecutableChanged, this, - [this](const Utils::FileName &stackExe) { - processParameters()->setCommand(stackExe.toString()); + [this](const Utils::FilePath &stackExe) { + processParameters()->setCommand(stackExe); }); connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, this, updateArguments); connect(buildConfiguration(), &BuildConfiguration::environmentChanged, this, updateEnvironment); |