summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/jscodemarker.cpp
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-06 17:52:38 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-06 17:52:38 (GMT)
commitbb6d5d9eb2a40de14ab3a41fbdaf4092c1a3b4e8 (patch)
tree44614b8add20ea5f89e3cbe5e87ba8b9eff1e781 /tools/qdoc3/jscodemarker.cpp
parent6834727fff1f74e15b2c9f25af1845e7f529afaa (diff)
downloadQt-bb6d5d9eb2a40de14ab3a41fbdaf4092c1a3b4e8.zip
Qt-bb6d5d9eb2a40de14ab3a41fbdaf4092c1a3b4e8.tar.gz
Qt-bb6d5d9eb2a40de14ab3a41fbdaf4092c1a3b4e8.tar.bz2
Added missing qmlcodemarker.cpp and qmlcodemarker.h files.
Added code to remove pragmas before parsing and add them to the output. The extractPragmas() function was copied into both qmlcodeparser.cpp and qmlcodemarker.cpp from src/declarative/qml/qdeclarativescriptparser.cpp, and was modified to return either nothing (for the API parser) or a list of removed pragmas (for the code marker).
Diffstat (limited to 'tools/qdoc3/jscodemarker.cpp')
-rw-r--r--tools/qdoc3/jscodemarker.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/qdoc3/jscodemarker.cpp b/tools/qdoc3/jscodemarker.cpp
index 8b6a31d..84a28c6 100644
--- a/tools/qdoc3/jscodemarker.cpp
+++ b/tools/qdoc3/jscodemarker.cpp
@@ -75,7 +75,10 @@ bool JsCodeMarker::recognizeCode(const QString &code)
QDeclarativeJS::Lexer lexer(&engine);
QDeclarativeJS::Parser parser(&engine);
QDeclarativeJS::NodePool m_nodePool("<JsCodeMarker::recognizeCode>", &engine);
- lexer.setCode(code, 1);
+
+ QString newCode = code;
+ QList<QDeclarativeJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ lexer.setCode(newCode, 1);
return parser.parseProgram();
}
@@ -111,7 +114,10 @@ QString JsCodeMarker::addMarkUp(const QString &code,
{
QDeclarativeJS::Engine engine;
QDeclarativeJS::Lexer lexer(&engine);
- lexer.setCode(code, 1);
+
+ QString newCode = code;
+ QList<QDeclarativeJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ lexer.setCode(newCode, 1);
QDeclarativeJS::Parser parser(&engine);
QDeclarativeJS::NodePool m_nodePool("<JsCodeMarker::addMarkUp>", &engine);
@@ -119,7 +125,9 @@ QString JsCodeMarker::addMarkUp(const QString &code,
if (parser.parseProgram()) {
QDeclarativeJS::AST::Node *ast = parser.rootNode();
- QmlMarkupVisitor visitor(code, &engine);
+ // Pass the unmodified code to the visitor so that pragmas and other
+ // unhandled source text can be output.
+ QmlMarkupVisitor visitor(code, pragmas, &engine);
QDeclarativeJS::AST::Node::accept(ast, &visitor);
output = visitor.markedUpCode();
}