void QmlMarkupVisitor::addVerbatim(QDeclarativeJS::AST::SourceLocation first,
                                   QDeclarativeJS::AST::SourceLocation last)
{
    if (!first.isValid())
        return;

    quint32 start = first.begin();
    quint32 finish;
    if (last.isValid())
        finish = last.end();
    else
        finish = first.end();

    if (cursor < start)
        addExtra(cursor, start);
    else if (cursor > start)
        return;

    QString text = source.mid(start, finish - start);
    output += protect(text);
    cursor = finish;
}
Esempio n. 2
0
QDeclarativeJS::AST::SourceLocation QmlDocVisitor::precedingComment(unsigned offset) const
{
    QDeclarativeJS::AST::SourceLocation currentLoc;

    foreach (const QDeclarativeJS::AST::SourceLocation &loc, engine->comments()) {
        if (loc.begin() > lastEndOffset && loc.end() < offset)
            currentLoc = loc;
        else
            break;
    }
    if (currentLoc.isValid()) {
        QString comment = document.mid(currentLoc.offset, currentLoc.length);
        if (comment.startsWith("!") || comment.startsWith("*"))
            return currentLoc;
    }

    return QDeclarativeJS::AST::SourceLocation();
}
void QmlMarkupVisitor::addMarkedUpToken(
    QDeclarativeJS::AST::SourceLocation &location, const QString &tagName,
    const QHash<QString, QString> &attributes)
{
    if (!location.isValid())
        return;

    if (cursor < location.offset)
        addExtra(cursor, location.offset);
    else if (cursor > location.offset)
        return;

    output += QString(QLatin1String("<@%1")).arg(tagName);
    foreach (const QString &key, attributes)
        output += QString(QLatin1String(" %1=\"%2\"")).arg(key).arg(attributes[key]);
    output += QString(QLatin1String(">%2</@%3>")).arg(protect(sourceText(location)), tagName);
    cursor += location.length;
}
Esempio n. 4
0
void QmlDocVisitor::applyDocumentation(QDeclarativeJS::AST::SourceLocation location,
                                    Node *node)
{
    QDeclarativeJS::AST::SourceLocation loc = precedingComment(location.begin());

    if (loc.isValid()) {
        QString source = document.mid(loc.offset, loc.length);

        Location start(filePath);
        start.setLineNo(loc.startLine);
        start.setColumnNo(loc.startColumn);
        Location finish(filePath);
        finish.setLineNo(loc.startLine);
        finish.setColumnNo(loc.startColumn);

        Doc doc(start, finish, source.mid(1), commands);
        node->setDoc(doc);

        usedComments.insert(loc.offset);
    }
}
Esempio n. 5
0
void QmlDocVisitor::applyDocumentation(QDeclarativeJS::AST::SourceLocation location,
                                       Node *node)
{
    QDeclarativeJS::AST::SourceLocation loc = precedingComment(location.begin());

    if (loc.isValid()) {
        QString source = document.mid(loc.offset, loc.length);
        if (source.startsWith(QLatin1String("!")) ||
                (source.startsWith(QLatin1String("*")) &&
                 source[1] != QLatin1Char('*'))) {

            Location start(filePath);
            start.setLineNo(loc.startLine);
            start.setColumnNo(loc.startColumn);
            Location finish(filePath);
            finish.setLineNo(loc.startLine);
            finish.setColumnNo(loc.startColumn);

            Doc doc(start, finish, source.mid(1), commands);
            node->setDoc(doc);
        }
    }
}