GammaRay icon indicating copy to clipboard operation
GammaRay copied to clipboard

Feature: Add a way to do massive semantic checks on qml files.

Open iamsergio opened this issue 10 years ago • 0 comments

Add a way to execute a mass QQmlComponent::create() on all qml files, for a given qml context, to find errors in qml files.

    QDirIterator dirIt(QLatin1String("."), QDirIterator::Subdirectories);
    while (dirIt.hasNext()) {
        dirIt.next();
        if (QFileInfo(dirIt.filePath()).isFile()) {
            if (QFileInfo(dirIt.filePath()).suffix() == QLatin1String("qml")) 
{
                qDebug()<< dirIt.filePath();
                QQmlComponent component(qmlengine(), 
QUrl::fromLocalFile(dirIt.filePath()));
                QObject *myObject = component.create();
                if (!myObject) {
                    qWarning() << dirIt.filePath();
                    foreach (const QQmlError &error, component.errors()) {
                        qWarning() << error;
                    }
                }
            }
        }
    }

iamsergio avatar Aug 05 '14 14:08 iamsergio