summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/rewriter/rewriter.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 01:17:20 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 01:17:20 (GMT)
commit4058b501914216bf28ab62c02b78abcbf7f5a3c9 (patch)
tree5dc502f69aa8f2151c9adfee3580f1d1aa0833aa /src/declarative/qml/rewriter/rewriter.cpp
parent334e406ff6441d3980741683714087c59c7dd123 (diff)
downloadQt-4058b501914216bf28ab62c02b78abcbf7f5a3c9.zip
Qt-4058b501914216bf28ab62c02b78abcbf7f5a3c9.tar.gz
Qt-4058b501914216bf28ab62c02b78abcbf7f5a3c9.tar.bz2
roberto: Added support for CSS like numeric literals e.g. 10p
Diffstat (limited to 'src/declarative/qml/rewriter/rewriter.cpp')
-rw-r--r--src/declarative/qml/rewriter/rewriter.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp
new file mode 100644
index 0000000..ec504fa
--- /dev/null
+++ b/src/declarative/qml/rewriter/rewriter.cpp
@@ -0,0 +1,55 @@
+#include "rewriter_p.h"
+#include "javascriptast_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace JavaScript;
+
+void Rewriter::replace(const AST::SourceLocation &loc, const QString &text)
+{ replace(loc.offset, loc.length, text); }
+
+void Rewriter::remove(const AST::SourceLocation &loc)
+{ return replace(loc.offset, loc.length, QString()); }
+
+void Rewriter::remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc)
+{ return replace(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, QString()); }
+
+void Rewriter::insertTextBefore(const AST::SourceLocation &loc, const QString &text)
+{ replace(loc.offset, 0, text); }
+
+void Rewriter::insertTextAfter(const AST::SourceLocation &loc, const QString &text)
+{ replace(loc.offset + loc.length, 0, text); }
+
+void Rewriter::replace(int offset, int length, const QString &text)
+{ textWriter.replace(offset, length, text); }
+
+void Rewriter::insertText(int offset, const QString &text)
+{ replace(offset, 0, text); }
+
+void Rewriter::removeText(int offset, int length)
+{ replace(offset, length, QString()); }
+
+QString Rewriter::textAt(const AST::SourceLocation &loc) const
+{ return _code.mid(loc.offset, loc.length); }
+
+QString Rewriter::textAt(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc) const
+{ return _code.mid(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset); }
+
+void Rewriter::accept(JavaScript::AST::Node *node)
+{ JavaScript::AST::Node::acceptChild(node, this); }
+
+void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc,
+ const AST::SourceLocation &lastLoc,
+ const AST::SourceLocation &loc)
+{
+ textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset);
+}
+
+void Rewriter::moveTextAfter(const AST::SourceLocation &firstLoc,
+ const AST::SourceLocation &lastLoc,
+ const AST::SourceLocation &loc)
+{
+ textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset + loc.length);
+}
+
+QT_END_NAMESPACE