15 |
15 |
16 class SessionReader(XMLStreamReaderBase): |
16 class SessionReader(XMLStreamReaderBase): |
17 """ |
17 """ |
18 Class for reading an XML session file. |
18 Class for reading an XML session file. |
19 """ |
19 """ |
20 supportedVersions = ["4.3", "4.4", "5.0", "6.0", "6.1", "6.2", "6.3", |
20 |
21 "6.4"] |
21 supportedVersions = ["4.3", "4.4", "5.0", "6.0", "6.1", "6.2", "6.3", "6.4"] |
22 |
22 |
23 def __init__(self, device, isGlobal): |
23 def __init__(self, device, isGlobal): |
24 """ |
24 """ |
25 Constructor |
25 Constructor |
26 |
26 |
27 @param device reference to the I/O device to read from |
27 @param device reference to the I/O device to read from |
28 @type QIODevice |
28 @type QIODevice |
29 @param isGlobal flag indicating to read the global session |
29 @param isGlobal flag indicating to read the global session |
30 @type bool |
30 @type bool |
31 """ |
31 """ |
32 XMLStreamReaderBase.__init__(self, device) |
32 XMLStreamReaderBase.__init__(self, device) |
33 |
33 |
34 self.version = "" |
34 self.version = "" |
35 self.isGlobal = isGlobal |
35 self.isGlobal = isGlobal |
36 |
36 |
37 self.project = ericApp().getObject("Project") |
37 self.project = ericApp().getObject("Project") |
38 self.projectBrowser = ericApp().getObject("ProjectBrowser") |
38 self.projectBrowser = ericApp().getObject("ProjectBrowser") |
39 self.multiProject = ericApp().getObject("MultiProject") |
39 self.multiProject = ericApp().getObject("MultiProject") |
40 self.vm = ericApp().getObject("ViewManager") |
40 self.vm = ericApp().getObject("ViewManager") |
41 self.dbg = ericApp().getObject("DebugUI") |
41 self.dbg = ericApp().getObject("DebugUI") |
42 self.dbs = ericApp().getObject("DebugServer") |
42 self.dbs = ericApp().getObject("DebugServer") |
43 |
43 |
44 if not self.isGlobal: |
44 if not self.isGlobal: |
45 # clear all breakpoints and bookmarks first |
45 # clear all breakpoints and bookmarks first |
46 # (in case we are rereading a session file) |
46 # (in case we are rereading a session file) |
47 files = self.project.getSources(True) |
47 files = self.project.getSources(True) |
48 for file in files: |
48 for file in files: |
49 editor = self.vm.getOpenEditor(file) |
49 editor = self.vm.getOpenEditor(file) |
50 if editor is not None: |
50 if editor is not None: |
51 editor.clearBookmarks() |
51 editor.clearBookmarks() |
52 self.dbs.getBreakPointModel().deleteAll() |
52 self.dbs.getBreakPointModel().deleteAll() |
53 self.dbs.getWatchPointModel().deleteAll() |
53 self.dbs.getWatchPointModel().deleteAll() |
54 |
54 |
55 def readXML(self, quiet=False): |
55 def readXML(self, quiet=False): |
56 """ |
56 """ |
57 Public method to read and parse the XML document. |
57 Public method to read and parse the XML document. |
58 |
58 |
59 @param quiet flag indicating quiet operations. |
59 @param quiet flag indicating quiet operations. |
60 If this flag is true, no errors are reported. |
60 If this flag is true, no errors are reported. |
61 @type bool |
61 @type bool |
62 """ |
62 """ |
63 while not self.atEnd(): |
63 while not self.atEnd(): |
64 self.readNext() |
64 self.readNext() |
65 if self.isStartElement(): |
65 if self.isStartElement(): |
66 if self.name() == "Session": |
66 if self.name() == "Session": |
67 self.version = self.attribute( |
67 self.version = self.attribute("version", sessionFileFormatVersion) |
68 "version", sessionFileFormatVersion) |
|
69 if self.version not in self.supportedVersions: |
68 if self.version not in self.supportedVersions: |
70 self.raiseUnsupportedFormatVersion(self.version) |
69 self.raiseUnsupportedFormatVersion(self.version) |
71 elif self.name() == "MultiProject": |
70 elif self.name() == "MultiProject": |
72 self.multiProject.openMultiProject( |
71 self.multiProject.openMultiProject(self.readElementText(), False) |
73 self.readElementText(), False) |
|
74 elif self.name() == "Project": |
72 elif self.name() == "Project": |
75 self.project.openProject(self.readElementText(), False) |
73 self.project.openProject(self.readElementText(), False) |
76 elif self.name() == "Filenames": |
74 elif self.name() == "Filenames": |
77 self.__readFilenames() |
75 self.__readFilenames() |
78 elif self.name() == "ActiveWindow": |
76 elif self.name() == "ActiveWindow": |
99 orientation = int(self.attribute("orientation", "1")) |
97 orientation = int(self.attribute("orientation", "1")) |
100 self.vm.setSplitOrientation(orientation) |
98 self.vm.setSplitOrientation(orientation) |
101 self.vm.setSplitCount(splitCount) |
99 self.vm.setSplitCount(splitCount) |
102 else: |
100 else: |
103 self.raiseUnexpectedStartTag(self.name()) |
101 self.raiseUnexpectedStartTag(self.name()) |
104 |
102 |
105 if not quiet: |
103 if not quiet: |
106 self.showErrorMessage() |
104 self.showErrorMessage() |
107 |
105 |
108 def __readFilenames(self): |
106 def __readFilenames(self): |
109 """ |
107 """ |
110 Private method to read the file name infos. |
108 Private method to read the file name infos. |
111 """ |
109 """ |
112 editorDict = {} |
110 editorDict = {} |
113 while not self.atEnd(): |
111 while not self.atEnd(): |
114 self.readNext() |
112 self.readNext() |
115 if self.isEndElement() and self.name() == "Filenames": |
113 if self.isEndElement() and self.name() == "Filenames": |
116 break |
114 break |
117 |
115 |
118 if self.isStartElement(): |
116 if self.isStartElement(): |
119 if self.name() == "Filename": |
117 if self.name() == "Filename": |
120 cline = int(self.attribute("cline", "0")) |
118 cline = int(self.attribute("cline", "0")) |
121 cindex = int(self.attribute("cindex", "0")) |
119 cindex = int(self.attribute("cindex", "0")) |
122 folds = self.attribute("folds") |
120 folds = self.attribute("folds") |
123 if folds: |
121 if folds: |
124 folds = [int(f) - 1 for f in folds.split(',')] |
122 folds = [int(f) - 1 for f in folds.split(",")] |
125 else: |
123 else: |
126 folds = [] |
124 folds = [] |
127 zoom = int(self.attribute("zoom", "-9999")) |
125 zoom = int(self.attribute("zoom", "-9999")) |
128 cloned = bool(int(self.attribute("cloned", "0"))) |
126 cloned = bool(int(self.attribute("cloned", "0"))) |
129 splitIndex = int(self.attribute("splitindex", "0")) |
127 splitIndex = int(self.attribute("splitindex", "0")) |
130 editorIndex = int(self.attribute("editorindex", "-1")) |
128 editorIndex = int(self.attribute("editorindex", "-1")) |
131 filename = self.readElementText() |
129 filename = self.readElementText() |
132 |
130 |
133 if cloned and filename in editorDict: |
131 if cloned and filename in editorDict: |
134 editor = editorDict[filename] |
132 editor = editorDict[filename] |
135 ed = self.vm.newEditorView( |
133 ed = self.vm.newEditorView( |
136 filename, editor, editor.getFileType(), |
134 filename, |
137 indexes=(splitIndex, editorIndex)) |
135 editor, |
|
136 editor.getFileType(), |
|
137 indexes=(splitIndex, editorIndex), |
|
138 ) |
138 else: |
139 else: |
139 ed = self.vm.openSourceFile( |
140 ed = self.vm.openSourceFile( |
140 filename, indexes=(splitIndex, editorIndex)) |
141 filename, indexes=(splitIndex, editorIndex) |
|
142 ) |
141 editorDict[filename] = ed |
143 editorDict[filename] = ed |
142 if ed is not None: |
144 if ed is not None: |
143 if zoom > -9999: |
145 if zoom > -9999: |
144 ed.zoomTo(zoom) |
146 ed.zoomTo(zoom) |
145 if folds: |
147 if folds: |
147 ed.setContractedFolds(folds) |
149 ed.setContractedFolds(folds) |
148 ed.setCursorPosition(cline, cindex) |
150 ed.setCursorPosition(cline, cindex) |
149 ed.ensureCursorVisible() |
151 ed.ensureCursorVisible() |
150 else: |
152 else: |
151 self.raiseUnexpectedStartTag(self.name()) |
153 self.raiseUnexpectedStartTag(self.name()) |
152 |
154 |
153 def __readBreakpoints(self): |
155 def __readBreakpoints(self): |
154 """ |
156 """ |
155 Private method to read the break point infos. |
157 Private method to read the break point infos. |
156 """ |
158 """ |
157 while not self.atEnd(): |
159 while not self.atEnd(): |
158 self.readNext() |
160 self.readNext() |
159 if self.isEndElement() and self.name() == "Breakpoints": |
161 if self.isEndElement() and self.name() == "Breakpoints": |
160 break |
162 break |
161 |
163 |
162 if self.isStartElement(): |
164 if self.isStartElement(): |
163 if self.name() == "Breakpoint": |
165 if self.name() == "Breakpoint": |
164 self.__readBreakpoint() |
166 self.__readBreakpoint() |
165 else: |
167 else: |
166 self.raiseUnexpectedStartTag(self.name()) |
168 self.raiseUnexpectedStartTag(self.name()) |
167 |
169 |
168 def __readBreakpoint(self): |
170 def __readBreakpoint(self): |
169 """ |
171 """ |
170 Private method to read the break point info. |
172 Private method to read the break point info. |
171 """ |
173 """ |
172 filename = "" |
174 filename = "" |
173 lineno = 0 |
175 lineno = 0 |
174 bpCond = "" |
176 bpCond = "" |
175 bpTemp = False |
177 bpTemp = False |
176 bpEnabled = True |
178 bpEnabled = True |
177 bpCount = 0 |
179 bpCount = 0 |
178 |
180 |
179 while not self.atEnd(): |
181 while not self.atEnd(): |
180 self.readNext() |
182 self.readNext() |
181 if self.isEndElement() and self.name() == "Breakpoint": |
183 if self.isEndElement() and self.name() == "Breakpoint": |
182 self.dbs.getBreakPointModel().addBreakPoint( |
184 self.dbs.getBreakPointModel().addBreakPoint( |
183 filename, lineno, (bpCond, bpTemp, bpEnabled, bpCount)) |
185 filename, lineno, (bpCond, bpTemp, bpEnabled, bpCount) |
184 break |
186 ) |
185 |
187 break |
|
188 |
186 if self.isStartElement(): |
189 if self.isStartElement(): |
187 if self.name() == "BpFilename": |
190 if self.name() == "BpFilename": |
188 filename = self.readElementText() |
191 filename = self.readElementText() |
189 elif self.name() == "Linenumber": |
192 elif self.name() == "Linenumber": |
190 lineno = int(self.attribute("value", "0")) |
193 lineno = int(self.attribute("value", "0")) |
191 elif self.name() == "Condition": |
194 elif self.name() == "Condition": |
192 bpCond = self.readElementText() |
195 bpCond = self.readElementText() |
193 if bpCond == 'None': |
196 if bpCond == "None": |
194 bpCond = '' |
197 bpCond = "" |
195 elif self.name() == "Temporary": |
198 elif self.name() == "Temporary": |
196 bpTemp = self.toBool(self.attribute("value", "False")) |
199 bpTemp = self.toBool(self.attribute("value", "False")) |
197 elif self.name() == "Enabled": |
200 elif self.name() == "Enabled": |
198 bpEnabled = self.toBool(self.attribute("value", "True")) |
201 bpEnabled = self.toBool(self.attribute("value", "True")) |
199 elif self.name() == "Count": |
202 elif self.name() == "Count": |
200 bpCount = int(self.attribute("value", "0")) |
203 bpCount = int(self.attribute("value", "0")) |
201 else: |
204 else: |
202 self.raiseUnexpectedStartTag(self.name()) |
205 self.raiseUnexpectedStartTag(self.name()) |
203 |
206 |
204 def __readWatchexpressions(self): |
207 def __readWatchexpressions(self): |
205 """ |
208 """ |
206 Private method to read watch expression infos. |
209 Private method to read watch expression infos. |
207 """ |
210 """ |
208 while not self.atEnd(): |
211 while not self.atEnd(): |
209 self.readNext() |
212 self.readNext() |
210 if self.isEndElement() and self.name() == "Watchexpressions": |
213 if self.isEndElement() and self.name() == "Watchexpressions": |
211 break |
214 break |
212 |
215 |
213 if self.isStartElement(): |
216 if self.isStartElement(): |
214 if self.name() == "Watchexpression": |
217 if self.name() == "Watchexpression": |
215 self.__readWatchexpression() |
218 self.__readWatchexpression() |
216 else: |
219 else: |
217 self.raiseUnexpectedStartTag(self.name()) |
220 self.raiseUnexpectedStartTag(self.name()) |
218 |
221 |
219 def __readWatchexpression(self): |
222 def __readWatchexpression(self): |
220 """ |
223 """ |
221 Private method to read the watch expression info. |
224 Private method to read the watch expression info. |
222 """ |
225 """ |
223 weCond = "" |
226 weCond = "" |
224 weTemp = False |
227 weTemp = False |
225 weEnabled = True |
228 weEnabled = True |
226 weCount = 0 |
229 weCount = 0 |
227 weSpecialCond = "" |
230 weSpecialCond = "" |
228 |
231 |
229 while not self.atEnd(): |
232 while not self.atEnd(): |
230 self.readNext() |
233 self.readNext() |
231 if self.isEndElement() and self.name() == "Watchexpression": |
234 if self.isEndElement() and self.name() == "Watchexpression": |
232 self.dbs.getWatchPointModel().addWatchPoint( |
235 self.dbs.getWatchPointModel().addWatchPoint( |
233 weCond, weSpecialCond, (weTemp, weEnabled, weCount)) |
236 weCond, weSpecialCond, (weTemp, weEnabled, weCount) |
234 break |
237 ) |
235 |
238 break |
|
239 |
236 if self.isStartElement(): |
240 if self.isStartElement(): |
237 if self.name() == "Condition": |
241 if self.name() == "Condition": |
238 weCond = self.readElementText() |
242 weCond = self.readElementText() |
239 if weCond == 'None': |
243 if weCond == "None": |
240 weCond = '' |
244 weCond = "" |
241 elif self.name() == "Temporary": |
245 elif self.name() == "Temporary": |
242 weTemp = self.toBool(self.attribute("value", "False")) |
246 weTemp = self.toBool(self.attribute("value", "False")) |
243 elif self.name() == "Enabled": |
247 elif self.name() == "Enabled": |
244 weEnabled = self.toBool(self.attribute("value", "True")) |
248 weEnabled = self.toBool(self.attribute("value", "True")) |
245 elif self.name() == "Count": |
249 elif self.name() == "Count": |
246 weCount = int(self.attribute("value", "0")) |
250 weCount = int(self.attribute("value", "0")) |
247 elif self.name() == "Special": |
251 elif self.name() == "Special": |
248 weSpecialCond = self.readElementText() |
252 weSpecialCond = self.readElementText() |
249 else: |
253 else: |
250 self.raiseUnexpectedStartTag(self.name()) |
254 self.raiseUnexpectedStartTag(self.name()) |
251 |
255 |
252 def __readDebugInfo(self): |
256 def __readDebugInfo(self): |
253 """ |
257 """ |
254 Private method to read the debug infos. |
258 Private method to read the debug infos. |
255 """ |
259 """ |
256 dbgExcList = [] |
260 dbgExcList = [] |
257 dbgExcIgnoreList = [] |
261 dbgExcIgnoreList = [] |
258 |
262 |
259 while not self.atEnd(): |
263 while not self.atEnd(): |
260 self.readNext() |
264 self.readNext() |
261 if self.isEndElement(): |
265 if self.isEndElement(): |
262 if self.name() == "DebugInfo": |
266 if self.name() == "DebugInfo": |
263 break |
267 break |
339 self.dbg.setEnableGlobalConfigOverride(configOverride) |
342 self.dbg.setEnableGlobalConfigOverride(configOverride) |
340 if not self.isGlobal: |
343 if not self.isGlobal: |
341 self.project.dbgGlobalConfigOverride = configOverride |
344 self.project.dbgGlobalConfigOverride = configOverride |
342 else: |
345 else: |
343 self.raiseUnexpectedStartTag(self.name()) |
346 self.raiseUnexpectedStartTag(self.name()) |
344 |
347 |
345 def __readBookmarks(self): |
348 def __readBookmarks(self): |
346 """ |
349 """ |
347 Private method to read the bookmark infos. |
350 Private method to read the bookmark infos. |
348 """ |
351 """ |
349 while not self.atEnd(): |
352 while not self.atEnd(): |
350 self.readNext() |
353 self.readNext() |
351 if self.isEndElement() and self.name() == "Bookmarks": |
354 if self.isEndElement() and self.name() == "Bookmarks": |
352 break |
355 break |
353 |
356 |
354 if self.isStartElement(): |
357 if self.isStartElement(): |
355 if self.name() == "Bookmark": |
358 if self.name() == "Bookmark": |
356 self.__readBookmark() |
359 self.__readBookmark() |
357 else: |
360 else: |
358 self.raiseUnexpectedStartTag(self.name()) |
361 self.raiseUnexpectedStartTag(self.name()) |
359 |
362 |
360 def __readBookmark(self): |
363 def __readBookmark(self): |
361 """ |
364 """ |
362 Private method to read the bookmark info. |
365 Private method to read the bookmark info. |
363 """ |
366 """ |
364 filename = "" |
367 filename = "" |
365 lineno = 0 |
368 lineno = 0 |
366 |
369 |
367 while not self.atEnd(): |
370 while not self.atEnd(): |
368 self.readNext() |
371 self.readNext() |
369 if self.isEndElement() and self.name() == "Bookmark": |
372 if self.isEndElement() and self.name() == "Bookmark": |
370 editor = self.vm.getOpenEditor(filename) |
373 editor = self.vm.getOpenEditor(filename) |
371 if editor is not None: |
374 if editor is not None: |
372 editor.toggleBookmark(lineno) |
375 editor.toggleBookmark(lineno) |
373 break |
376 break |
374 |
377 |
375 if self.isStartElement(): |
378 if self.isStartElement(): |
376 if self.name() == "BmFilename": |
379 if self.name() == "BmFilename": |
377 filename = self.readElementText() |
380 filename = self.readElementText() |
378 elif self.name() == "Linenumber": |
381 elif self.name() == "Linenumber": |
379 lineno = int(self.attribute("value", "0")) |
382 lineno = int(self.attribute("value", "0")) |
380 else: |
383 else: |
381 self.raiseUnexpectedStartTag(self.name()) |
384 self.raiseUnexpectedStartTag(self.name()) |
382 |
385 |
383 def __readProjectBrowserStates(self): |
386 def __readProjectBrowserStates(self): |
384 """ |
387 """ |
385 Private method to read the project browser state infos. |
388 Private method to read the project browser state infos. |
386 """ |
389 """ |
387 while not self.atEnd(): |
390 while not self.atEnd(): |
388 self.readNext() |
391 self.readNext() |
389 if self.isEndElement() and self.name() == "ProjectBrowserStates": |
392 if self.isEndElement() and self.name() == "ProjectBrowserStates": |
390 break |
393 break |
391 |
394 |
392 if self.isStartElement(): |
395 if self.isStartElement(): |
393 if self.name() == "ProjectBrowserState": |
396 if self.name() == "ProjectBrowserState": |
394 browserName = self.attribute("name", "") |
397 browserName = self.attribute("name", "") |
395 if not browserName: |
398 if not browserName: |
396 self.raiseBadValue("ProjectBrowserState.name") |
399 self.raiseBadValue("ProjectBrowserState.name") |
397 self.__readProjectBrowserState(browserName) |
400 self.__readProjectBrowserState(browserName) |
398 else: |
401 else: |
399 self.raiseUnexpectedStartTag(self.name()) |
402 self.raiseUnexpectedStartTag(self.name()) |
400 |
403 |
401 def __readProjectBrowserState(self, browserName): |
404 def __readProjectBrowserState(self, browserName): |
402 """ |
405 """ |
403 Private method to read the project browser state info. |
406 Private method to read the project browser state info. |
404 |
407 |
405 @param browserName name of the project browser |
408 @param browserName name of the project browser |
406 @type str |
409 @type str |
407 """ |
410 """ |
408 expandedNames = [] |
411 expandedNames = [] |
409 |
412 |
410 while not self.atEnd(): |
413 while not self.atEnd(): |
411 self.readNext() |
414 self.readNext() |
412 if self.isEndElement() and self.name() == "ProjectBrowserState": |
415 if self.isEndElement() and self.name() == "ProjectBrowserState": |
413 projectBrowser = self.projectBrowser.getProjectBrowser( |
416 projectBrowser = self.projectBrowser.getProjectBrowser(browserName) |
414 browserName) |
|
415 if projectBrowser is not None: |
417 if projectBrowser is not None: |
416 projectBrowser.expandItemsByName(expandedNames) |
418 projectBrowser.expandItemsByName(expandedNames) |
417 break |
419 break |
418 |
420 |
419 if self.isStartElement(): |
421 if self.isStartElement(): |
420 if self.name() == "ExpandedItemName": |
422 if self.name() == "ExpandedItemName": |
421 itemName = self.readElementText() |
423 itemName = self.readElementText() |
422 if itemName: |
424 if itemName: |
423 expandedNames.append(itemName) |
425 expandedNames.append(itemName) |