diff --git a/src/plugins/duieditor/duidocument.cpp b/src/plugins/duieditor/duidocument.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bd987e46bb3f4b671756d1d1e097f8e652f49f45
--- /dev/null
+++ b/src/plugins/duieditor/duidocument.cpp
@@ -0,0 +1,77 @@
+#include "duidocument.h"
+#include "parser/javascriptast_p.h"
+#include "parser/javascriptlexer_p.h"
+#include "parser/javascriptparser_p.h"
+#include "parser/javascriptengine_p.h"
+#include "parser/javascriptnodepool_p.h"
+
+using namespace DuiEditor;
+using namespace DuiEditor::Internal;
+using namespace JavaScript;
+
+DuiDocument::DuiDocument(const QString &fileName)
+    : _engine(0), _pool(0), _program(0), _fileName(fileName)
+{
+}
+
+DuiDocument::~DuiDocument()
+{
+    delete _engine;
+    delete _pool;
+}
+
+DuiDocument::Ptr DuiDocument::create(const QString &fileName)
+{
+    DuiDocument::Ptr doc(new DuiDocument(fileName));
+    return doc;
+}
+
+AST::UiProgram *DuiDocument::program() const
+{
+    return _program;
+}
+
+QList<JavaScriptParser::DiagnosticMessage> DuiDocument::diagnosticMessages() const
+{
+    return _diagnosticMessages;
+}
+
+void DuiDocument::setSource(const QString &source)
+{
+    _source = source;
+}
+
+bool DuiDocument::parse()
+{
+    Q_ASSERT(! _engine);
+    Q_ASSERT(! _pool);
+    Q_ASSERT(! _program);
+
+    _engine = new JavaScriptEnginePrivate();
+    _pool = new NodePool(_fileName, _engine);
+
+    JavaScriptParser parser;
+
+    NodePool nodePool(_fileName, _engine);
+    _engine->setNodePool(_pool);
+
+    Lexer lexer(_engine);
+    _engine->setLexer(&lexer);
+
+    lexer.setCode(_source, /*line = */ 1);
+
+    bool parsed = parser.parse(_engine);
+    _program = parser.ast();
+    _diagnosticMessages = parser.diagnosticMessages();
+    return parsed;
+}
+
+Snapshot::Snapshot()
+{
+}
+
+Snapshot::~Snapshot()
+{
+}
+
+
diff --git a/src/plugins/duieditor/duidocument.h b/src/plugins/duieditor/duidocument.h
new file mode 100644
index 0000000000000000000000000000000000000000..4449cb8d886b3a5d1a9e5e6f9c649edf0b373826
--- /dev/null
+++ b/src/plugins/duieditor/duidocument.h
@@ -0,0 +1,66 @@
+#ifndef DUIDOCUMENT_H
+#define DUIDOCUMENT_H
+
+#include <QtCore/QSharedPointer>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+
+#include "parser/javascriptparser_p.h"
+
+class JavaScriptEnginePrivate;
+
+namespace JavaScript {
+
+class NodePool;
+
+namespace AST {
+
+class UiProgram;
+
+} // end of namespace AST
+} // end of namespace JavaScript
+
+
+
+namespace DuiEditor {
+namespace Internal {
+
+class DuiDocument
+{
+public:
+    typedef QSharedPointer<DuiDocument> Ptr;
+
+protected:
+    DuiDocument(const QString &fileName);
+
+public:
+    ~DuiDocument();
+
+    static DuiDocument::Ptr create(const QString &fileName);
+
+    JavaScript::AST::UiProgram *program() const;
+    QList<JavaScriptParser::DiagnosticMessage> diagnosticMessages() const;
+
+    void setSource(const QString &source);
+    bool parse();
+
+private:
+    JavaScriptEnginePrivate *_engine;
+    JavaScript::NodePool *_pool;
+    JavaScript::AST::UiProgram *_program;
+    QList<JavaScriptParser::DiagnosticMessage> _diagnosticMessages;
+    QString _fileName;
+    QString _source;
+};
+
+class Snapshot: public QMap<QString, DuiDocument>
+{
+public:
+    Snapshot();
+    ~Snapshot();
+};
+
+} // end of namespace Internal
+} // emd of namespace DuiEditor
+
+#endif // DUIDOCUMENT_H
diff --git a/src/plugins/duieditor/duieditor.cpp b/src/plugins/duieditor/duieditor.cpp
index 263040207c506c22b61337eae2f146cb1585d9e7..ddae6b2939d70c714a50b935cdbdb094c8f95feb 100644
--- a/src/plugins/duieditor/duieditor.cpp
+++ b/src/plugins/duieditor/duieditor.cpp
@@ -31,15 +31,13 @@
 #include "duieditorconstants.h"
 #include "duihighlighter.h"
 #include "duieditorplugin.h"
+#include "duidocument.h"
 
 #include "rewriter/rewriter.h"
 
-#include "parser/javascriptengine_p.h"
-#include "parser/javascriptparser_p.h"
-#include "parser/javascriptlexer_p.h"
-#include "parser/javascriptnodepool_p.h"
 #include "parser/javascriptastvisitor_p.h"
 #include "parser/javascriptast_p.h"
+#include "parser/javascriptengine_p.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/actionmanager/actionmanager.h>
@@ -435,29 +433,21 @@ void ScriptEditor::updateDocumentNow()
     m_updateDocumentTimer->stop();
 
     const QString fileName = file()->fileName();
-    const QString code = toPlainText();
-
-    JavaScriptParser parser;
-    JavaScriptEnginePrivate driver;
-
-    NodePool nodePool(fileName, &driver);
-    driver.setNodePool(&nodePool);
-
-    Lexer lexer(&driver);
-    lexer.setCode(code, /*line = */ 1);
-    driver.setLexer(&lexer);
+    const QString source = toPlainText();
 
-    bool parsed = parser.parse(&driver);
+    DuiDocument::Ptr doc = DuiDocument::create(fileName);
+    doc->setSource(source);
+    bool parsed = doc->parse();
 
     FindIdDeclarations updateIds;
-    m_ids = updateIds(parser.ast());
+    m_ids = updateIds(doc->program());
 
     if (parsed) {
         FindDeclarations findDeclarations;
-        m_declarations = findDeclarations(parser.ast());
+        m_declarations = findDeclarations(doc->program());
 
         FindWords findWords;
-        m_words = findWords(parser.ast());
+        m_words = findWords(doc->program());
 
         QStringList items;
         items.append(tr("<Select Symbol>"));
@@ -478,7 +468,7 @@ void ScriptEditor::updateDocumentNow()
 
     QTextEdit::ExtraSelection sel;
 
-    m_diagnosticMessages = parser.diagnosticMessages();
+    m_diagnosticMessages = doc->diagnosticMessages();
 
     foreach (const JavaScriptParser::DiagnosticMessage &d, m_diagnosticMessages) {
         int line = d.loc.startLine;
diff --git a/src/plugins/duieditor/duieditor.pro b/src/plugins/duieditor/duieditor.pro
index 4d0992bb2486a20bda092ca5fd7d463b128462fa..bfbd34788c43676195c4e67f2fbc66357878c5ce 100644
--- a/src/plugins/duieditor/duieditor.pro
+++ b/src/plugins/duieditor/duieditor.pro
@@ -27,7 +27,8 @@ duihighlighter.h \
 duieditoractionhandler.h \
 duicodecompletion.h \
 duieditorconstants.h \
-duihoverhandler.h
+duihoverhandler.h \
+duidocument.h
 
 SOURCES += duieditor.cpp \
 duieditorfactory.cpp \
@@ -35,6 +36,7 @@ duieditorplugin.cpp \
 duihighlighter.cpp \
 duieditoractionhandler.cpp \
 duicodecompletion.cpp \
-duihoverhandler.cpp
+duihoverhandler.cpp \
+duidocument.cpp
 
 RESOURCES += duieditor.qrc