TODO plugin: Add file patterns to exclude from parsing

Additional list of regular expressions added to TODO plugin settings
to allow set patterns to be excluded from file list to parse by this plugin.

Change-Id: I718f111ac7592557a6aa86865283468c53d58078
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Denis Kormalev
2015-05-18 22:47:20 +03:00
parent 4f5a02d596
commit a429ef3d50
19 changed files with 455 additions and 95 deletions

View File

@@ -66,15 +66,22 @@ TodoItemsModel *TodoItemsProvider::todoItemsModel()
void TodoItemsProvider::settingsChanged(const Settings &newSettings)
{
if (newSettings.keywords != m_settings.keywords)
if (newSettings.keywords != m_settings.keywords) {
foreach (TodoItemsScanner *scanner, m_scanners)
scanner->setKeywordList(newSettings.keywords);
scanner->setParams(newSettings.keywords);
}
m_settings = newSettings;
updateList();
}
void TodoItemsProvider::projectSettingsChanged(Project *project)
{
Q_UNUSED(project);
updateList();
}
void TodoItemsProvider::updateList()
{
m_itemsList.clear();
@@ -84,9 +91,8 @@ void TodoItemsProvider::updateList()
if (m_currentEditor)
m_itemsList = m_itemsHash.value(m_currentEditor->document()->filePath().toString());
// Show only items of the startup project if any
} else {
if (m_startupProject)
setItemsListWithinStartupProject();
} else if (m_startupProject) {
setItemsListWithinStartupProject();
}
m_itemsModel->todoItemsListUpdated();
@@ -102,19 +108,34 @@ void TodoItemsProvider::createScanners()
if (QmlJS::ModelManagerInterface::instance())
m_scanners << new QmlJsTodoItemsScanner(m_settings.keywords, this);
foreach (TodoItemsScanner *scanner, m_scanners)
foreach (TodoItemsScanner *scanner, m_scanners) {
connect(scanner, SIGNAL(itemsFetched(QString,QList<TodoItem>)), this,
SLOT(itemsFetched(QString,QList<TodoItem>)), Qt::QueuedConnection);
}
}
void TodoItemsProvider::setItemsListWithinStartupProject()
{
QHashIterator<QString, QList<TodoItem> > it(m_itemsHash);
QSet<QString> fileNames = QSet<QString>::fromList(m_startupProject->files(Project::ExcludeGeneratedFiles));
QVariantMap settings = m_startupProject->namedSettings(QLatin1String(Constants::SETTINGS_NAME_KEY)).toMap();
while (it.hasNext()) {
it.next();
if (fileNames.contains(it.key()))
m_itemsList << it.value();
QString fileName = it.key();
if (fileNames.contains(fileName)) {
bool skip = false;
for (const QVariant &pattern : settings[QLatin1String(Constants::EXCLUDES_LIST_KEY)].toList()) {
QRegExp re(pattern.toString());
if (re.indexIn(fileName) != -1) {
skip = true;
break;
}
}
if (!skip)
m_itemsList << it.value();
}
}
}