KHtml

debugdocument.h
1 #ifndef DEBUGDOCUMENT_H
2 #define DEBUGDOCUMENT_H
3 
4 #include <QHash>
5 #include <QObject>
6 #include <QVector>
7 #include <QStringList>
8 
9 #include "misc/shared.h"
10 
11 namespace KJS
12 {
13 class Interpreter;
14 }
15 
16 namespace KTextEditor
17 {
18 class Document;
19 class View;
20 class Editor;
21 }
22 
23 namespace KJSDebugger
24 {
25 
26 class DebugDocument : public QObject, public khtml::Shared<DebugDocument>
27 {
28  Q_OBJECT
29 public:
30  typedef SharedPtr<DebugDocument> Ptr;
31 
32  DebugDocument(KJS::Interpreter *interp, const QString &url,
33  int sourceId, int baseLine, const QString &source);
34  ~DebugDocument();
35 
36  QString name() const;
37  QString url() const;
38  int sid() const;
39 
40  KTextEditor::Document *viewerDocument();
41  KTextEditor::View *viewerView();
42 
43  // Marks the document as being discarded for reload, so that new data should be set here.
44  void markReload();
45  bool isMarkedReload() const;
46 
47  void reloaded(int sourceId, const QString &source);
48 
49  void setBreakpoint(int lineNumber);
50  void removeBreakpoint(int lineNumber);
51  bool hasBreakpoint(int lineNumber);
52 
53  // We keep track of whether documents have functions, since we can't discard
54  // eval contexts that do
55  bool hasFunctions();
56  void setHasFunctions();
57 
58  KJS::Interpreter *interpreter();
59 
60  int baseLine() const;
61  int length() const;
62 
63 Q_SIGNALS:
64  void documentDestroyed(KJSDebugger::DebugDocument *);
65 private:
66  QString m_url;
67  QString m_name;
68  KJS::Interpreter *m_interpreter;
69 
70  bool m_hasFunctions;
71 
72  // This is set to true when we are rebuilding the document.
73  // in that case, the UI might get undesired mark add/remove events,
74  // and update the breakpoint set accordingly --- such as removing all of them
75  // on clear.
76  bool m_rebuilding;
77 
78  bool m_reload;
79 
80  int m_firstLine;
81  int m_sourceId;
82  QStringList m_sourceLines;
83  QString m_md5; // empty if invalid/not computed.
84 
85  void rebuildViewerDocument();
86  void setupViewerDocument();
87 
88  // We store breakpoints differently for scopes with URL
89  // and without it. Those that have it are stored globally,
90  // so that breakpoints persist across multiple visits of the
91  // document. For eval scopes, we store them based on the MD5
92  // of the source code.
93  static QHash<QString, QVector<int> > *s_perUrlBreakPoints;
94  static QHash<QString, QVector<int> > *s_perHashBreakPoints;
95 
96  QVector<int> &breakpoints();
97 
98  KTextEditor::Document *m_kteDoc;
99  KTextEditor::View *m_kteView;
100  static KTextEditor::Editor *s_kate;
101  static KTextEditor::Editor *kate();
102 };
103 
104 }
105 
106 #endif
QString name(const QVariant &location)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.