Skip to content

Commit

Permalink
improve detection of packages in child documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Nov 20, 2023
1 parent 0ff00b5 commit 2eb6c05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/latexdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ LatexDocument *LatexDocument::getMasterDocument() const
return masterDocument;
}

QList<LatexDocument *>LatexDocument::getListOfDocs(QSet<LatexDocument *> *visitedDocs)
QList<LatexDocument *>LatexDocument::getListOfDocs(QSet<LatexDocument *> *visitedDocs,bool onlyChildDocs)
{
QList<LatexDocument *>listOfDocs;
bool deleteVisitedDocs = false;
Expand All @@ -1805,10 +1805,10 @@ QList<LatexDocument *>LatexDocument::getListOfDocs(QSet<LatexDocument *> *visite
if (visitedDocs && !visitedDocs->contains(elem)) {
listOfDocs << elem;
visitedDocs->insert(elem);
listOfDocs << elem->getListOfDocs(visitedDocs);
listOfDocs << elem->getListOfDocs(visitedDocs,onlyChildDocs);
}
}
if (masterDocument) { //check masters
if (masterDocument && !onlyChildDocs) { //check masters
master = masterDocument;
if (!visitedDocs->contains(master))
listOfDocs << master->getListOfDocs(visitedDocs);
Expand Down Expand Up @@ -2464,7 +2464,7 @@ bool LatexDocuments::addDocsToLoad(QStringList filenames, LatexDocument *parentD
doc->patchStructure(0,-1);
doc->lp->append(doc->ltxCommands);
docForUpdate=doc;
newPackagesFound|=!doc->containedPackages().isEmpty();
newPackagesFound|=!doc->usedPackages(true).isEmpty();
}
}
if(docForUpdate){
Expand Down Expand Up @@ -3099,10 +3099,10 @@ QStringList LatexDocument::containedPackages()
* Return a list of packages that are available in the document.
* This includes all packages declared in all project files.
*/
QSet<QString> LatexDocument::usedPackages()
QSet<QString> LatexDocument::usedPackages(bool onlyInChildDocs)
{
QSet<QString> packages;
foreach (LatexDocument *doc, getListOfDocs()) {
foreach (LatexDocument *doc, getListOfDocs(nullptr,onlyInChildDocs)) {
packages.unite(convertStringListtoSet(doc->containedPackages()));
}
return packages;
Expand Down
4 changes: 2 additions & 2 deletions src/latexdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ class LatexDocument: public QDocument

Q_INVOKABLE QStringList includedFiles(bool importsOnly=false);
Q_INVOKABLE QStringList includedFilesAndParent();
Q_INVOKABLE QList<LatexDocument *> getListOfDocs(QSet<LatexDocument *> *visitedDocs = nullptr);
Q_INVOKABLE QList<LatexDocument *> getListOfDocs(QSet<LatexDocument *> *visitedDocs = nullptr,bool onlyChildDocs=false);

LatexParser ltxCommands; /// locally defined latex commands
QSharedPointer<LatexParser> lp;

Q_INVOKABLE bool containsPackage(const QString &name);
Q_INVOKABLE QStringList containedPackages();
Q_INVOKABLE QSet<QString> usedPackages();
Q_INVOKABLE QSet<QString> usedPackages(bool onlyInChildDocs=false);
bool updateCompletionFiles(const bool updatePackages=true,const bool updateUserCommands=true);
const QSet<QString> &getCWLFiles() const;

Expand Down

0 comments on commit 2eb6c05

Please sign in to comment.