logic: maven project setup

* added option to create a Coati project from a Maven POM file
* show list of indexed file paths in maven project setup
* use FileManager to detect indexed files in project setup (except cdb)
* added Maven path to preferences window and added path detectors.
* fixed: QtDialogView::hideStatusDialog now also hides loader in status bar.
* refactored ProjectType

fortune cookie message = If you continually give, you will continually have.
This commit is contained in:
malte_langkabel
2017-03-08 14:55:42 +01:00
parent d6f3099981
commit 3cbe83f9e6
83 changed files with 1502 additions and 545 deletions
+23 -1
View File
@@ -106,7 +106,21 @@ std::set<FilePath> FileManager::getSourceFilePaths() const
std::set<FilePath> sourceFilePaths;
for (const FileInfo& fileInfo: FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions))
{
sourceFilePaths.emplace(fileInfo.path);
const FilePath& path = fileInfo.path;
bool excluded = false;
for (FilePath p: m_excludePaths)
{
if (p == path || p.contains(path))
{
excluded = true;
break;
}
}
if (!excluded)
{
sourceFilePaths.emplace(path);
}
}
return sourceFilePaths;
}
@@ -115,6 +129,14 @@ bool FileManager::hasSourceFilePath(const FilePath& filePath) const
{
if (m_sourceFilePaths.find(filePath) != m_sourceFilePaths.end())
{
for (FilePath p: m_excludePaths)
{
if (p == filePath || p.contains(filePath))
{
return false;
}
}
return true;
}
+1 -1
View File
@@ -37,7 +37,7 @@ public:
std::set<FilePath> getSourceFilePaths() const;
// checks if file is in non-excluded source directory
virtual bool hasSourceFilePath(const FilePath& filePath) const;
bool hasSourceFilePath(const FilePath& filePath) const;
private:
std::vector<FilePath> makeCanonical(const std::vector<FilePath>& filePaths);
@@ -68,59 +68,6 @@ TiXmlElement* SolutionParserUtility::getFirstTagByName(TiXmlElement* root, const
return NULL;
}
std::vector<TiXmlElement*> SolutionParserUtility::getAllTagsByName(TiXmlElement* root, const std::string& tag)
{
std::vector<TiXmlElement*> nodes;
TiXmlElement* element = root;
while (element)
{
std::string value = element->Value();
if (value == tag)
{
nodes.push_back(element);
}
if (element->FirstChildElement() != NULL)
{
element = element->FirstChildElement();
}
else if (element->NextSiblingElement() != NULL)
{
element = element->NextSiblingElement();
}
else
{
if (element == NULL)
{
}
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
{
TiXmlElement* newElement = element->Parent()->ToElement();
if (newElement == NULL)
{
}
element = newElement;
}
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
{
element = element->Parent()->NextSiblingElement();
}
else
{
break;
}
}
}
return nodes;
}
TiXmlElement* SolutionParserUtility::getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute)
{
TiXmlElement* element = root;
@@ -284,7 +231,7 @@ std::string SolutionParserUtility::findAndResolveEnvironmentVariable(const std::
if (macro != "")
{
LOG_WARNING_STREAM(<< "Encountered IDE macro \"" << macro << "\"");
if (m_ideMacroValues.find(macro) == m_ideMacroValues.end())
{
LOG_WARNING_STREAM(<< "Could not resolve IDE macro \"" << macro << "\"");
@@ -358,7 +305,7 @@ std::string SolutionParserUtility::makePathCanonical(const std::string& path)
{
std::string what = e.what();
LOG_WARNING_STREAM(<< e.what());
std::stringstream errorMessage;
errorMessage << "Could not make path \"" << path << "\" canonical. Check if it really exists.";
MessageStatus(errorMessage.str(), true).dispatch();
@@ -11,7 +11,6 @@ class SolutionParserUtility
{
public:
static TiXmlElement* getFirstTagByName(TiXmlElement* root, const std::string& tag);
static std::vector<TiXmlElement*> getAllTagsByName(TiXmlElement* root, const std::string& tag);
static TiXmlElement* getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
static std::vector<TiXmlElement*> getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
@@ -24,7 +23,7 @@ public:
static std::string makePathCanonical(const std::string& path);
static std::string checkIsIdeMacro(const std::string& text); // returns matching macro or empty string if no match was found
static std::vector<std::string> m_ideMacros;
static std::map<std::string, std::string> m_ideMacroValues; // to replace macros with known values
};
+31
View File
@@ -2,6 +2,7 @@
#define UTILITY_H
#include <algorithm>
#include <cstdarg>
#include <deque>
#include <set>
#include <time.h>
@@ -47,6 +48,15 @@ namespace utility
template<typename T>
std::vector<T> toVector(const std::set<T>& d);
template<typename T>
void fillVectorWithElements(std::vector<T>& v, const T& arg);
template<typename T, typename... Args>
void fillVectorWithElements(std::vector<T>& v, const T& arg, const Args&... args);
template<typename T, typename... Args>
std::vector<T> createVectorFromElements(const Args&... args);
template<typename T>
std::vector<std::string> toStrings(const std::vector<T>& d);
template<>
@@ -156,6 +166,27 @@ std::vector<T> utility::toVector(const std::set<T>& d)
return v;
}
template<typename T>
void utility::fillVectorWithElements(std::vector<T>& v, const T& arg)
{
v.push_back(arg);
}
template<typename T, typename... Args>
void utility::fillVectorWithElements(std::vector<T>& v, const T& arg, const Args&... args)
{
fillVectorWithElements<T>(v, arg);
fillVectorWithElements<T>(v, args...);
}
template<typename T, typename... Args>
std::vector<T> utility::createVectorFromElements(const Args&... args)
{
std::vector<T> v;
fillVectorWithElements<T>(v, args...);
return v;
}
template<typename T>
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
{
+41
View File
@@ -211,6 +211,47 @@ namespace utility
return str;
}
std::string insertLineBreaksAtBlankSpaces(const std::string& s, int maxLineLength)
{
const std::vector<std::string> atoms = splitToVector(s, " ");
std::string ret = "";
std::string currentLine = "";
for (const std::string& atom: atoms)
{
if (currentLine.size() + 1 + atom.size() <= maxLineLength)
{
currentLine += " " + atom;
}
else
{
if (!ret.empty())
{
ret += "\n";
}
if (currentLine.empty())
{
ret += atom;
}
else
{
ret += currentLine;
currentLine = atom;
}
}
}
if (!currentLine.empty())
{
if (!ret.empty())
{
ret += "\n";
}
ret += currentLine;
}
return ret;
}
std::string trim(const std::string &str)
{
auto wsfront = std::find_if_not(str.begin(), str.end(), [](int c){ return std::isspace(c); });
+2
View File
@@ -45,6 +45,8 @@ namespace utility
std::string replace(std::string str, const std::string& from, const std::string& to);
std::string insertLineBreaksAtBlankSpaces(const std::string& s, int maxLineLength);
std::string trim(const std::string &str);
template <typename ContainerType>
+153
View File
@@ -0,0 +1,153 @@
#include "utility/utilityXml.h";
#include "tinyxml/tinyxml.h";
namespace utility
{
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags)
{
std::vector<std::string> values;
std::string text = textAccess->getText();
TiXmlDocument doc;
const char* pTest = doc.Parse(text.c_str(), 0, TIXML_ENCODING_LEGACY);
if (pTest != NULL)
{
TiXmlHandle docHandle(&doc);
std::vector<std::pair<TiXmlElement*, size_t>> traversalStates;
traversalStates.push_back(std::make_pair(docHandle.ToNode()->FirstChildElement(), 0));
while (!traversalStates.empty())
{
TiXmlElement* currentElement = traversalStates.back().first;
const size_t currentIndex = traversalStates.back().second;
traversalStates.pop_back();
if(currentElement != nullptr &&
currentElement->Value() == tags[currentIndex]
)
{
if (currentIndex < tags.size() - 1)
{
TiXmlElement* nextElement = currentElement->FirstChildElement();
while (nextElement)
{
traversalStates.push_back(std::make_pair(nextElement, size_t(currentIndex + 1)));
nextElement = nextElement->NextSiblingElement();
}
}
else
{
if (currentElement->FirstChild() &&
currentElement->FirstChild() == currentElement->LastChild() &&
currentElement->FirstChild()->ToText()
)
{
values.push_back(currentElement->FirstChild()->ToText()->Value());
}
}
}
}
}
else
{
// LOG_ERROR("Unable to load file.");
}
return values;
}
std::vector<std::string> getValuesOfAllXmlTagsByName(std::shared_ptr<TextAccess> textAccess, const std::string& tag)
{
std::vector<std::string> values;
std::string text = textAccess->getText();
TiXmlDocument doc;
const char* pTest = doc.Parse(text.c_str(), 0, TIXML_ENCODING_UTF8);
if (pTest != NULL)
{
TiXmlHandle docHandle(&doc);
TiXmlElement *rootElement = docHandle.ToNode()->FirstChildElement();
if(rootElement != nullptr)
{
for (TiXmlElement* element: getAllXmlTagsByName(rootElement, tag))
{
if (element->FirstChild() &&
element->FirstChild() == element->LastChild() &&
element->FirstChild()->ToText()
)
{
values.push_back(element->FirstChild()->ToText()->Value());
}
}
}
else
{
// LOG_ERROR("Unable to load file.");
}
}
else
{
// LOG_ERROR("Unable to load file.");
}
return values;
}
std::vector<TiXmlElement*> getAllXmlTagsByName(TiXmlElement* root, const std::string& tag)
{
std::vector<TiXmlElement*> nodes;
TiXmlElement* element = root;
while (element)
{
std::string value = element->Value();
if (value == tag)
{
nodes.push_back(element);
}
if (element->FirstChildElement() != NULL)
{
element = element->FirstChildElement();
}
else if (element->NextSiblingElement() != NULL)
{
element = element->NextSiblingElement();
}
else
{
if (element == NULL)
{
}
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
{
TiXmlElement* newElement = element->Parent()->ToElement();
if (newElement == NULL)
{
}
element = newElement;
}
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
{
element = element->Parent()->NextSiblingElement();
}
else
{
break;
}
}
}
return nodes;
}
}
+19
View File
@@ -0,0 +1,19 @@
#ifndef UTILITY_XML_H
#define UTILITY_XML_H
#include <memory>
#include <string>
#include <vector>
#include "utility/text/TextAccess.h"
class TiXmlElement;
namespace utility
{
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags);
std::vector<std::string> getValuesOfAllXmlTagsByName(std::shared_ptr<TextAccess> textAccess, const std::string& tag);
std::vector<TiXmlElement*> getAllXmlTagsByName(TiXmlElement* root, const std::string& tag);
}
#endif // UTILITY_XML_H