| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library trydart.interaction_manager; | 5 library trydart.interaction_manager; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 | 8 |
| 9 import 'dart:convert' show | 9 import 'dart:convert' show |
| 10 JSON; | 10 JSON; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 isCollapsed; | 59 isCollapsed; |
| 60 | 60 |
| 61 import 'editor.dart' as editor; | 61 import 'editor.dart' as editor; |
| 62 | 62 |
| 63 import 'mock.dart' as mock; | 63 import 'mock.dart' as mock; |
| 64 | 64 |
| 65 import 'settings.dart' as settings; | 65 import 'settings.dart' as settings; |
| 66 | 66 |
| 67 import 'shadow_root.dart' show | 67 import 'shadow_root.dart' show |
| 68 getShadowRoot, | 68 getShadowRoot, |
| 69 getText, |
| 69 removeShadowRootPolyfill, | 70 removeShadowRootPolyfill, |
| 70 setShadowRoot; | 71 setShadowRoot; |
| 71 | 72 |
| 72 const String TRY_DART_NEW_DEFECT = | 73 const String TRY_DART_NEW_DEFECT = |
| 73 'https://code.google.com/p/dart/issues/entry' | 74 'https://code.google.com/p/dart/issues/entry' |
| 74 '?template=Try+Dart+Internal+Error'; | 75 '?template=Try+Dart+Internal+Error'; |
| 75 | 76 |
| 76 /** | 77 /** |
| 77 * UI interaction manager for the entire application. | 78 * UI interaction manager for the entire application. |
| 78 */ | 79 */ |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 state = tokenizeAndHighlight( | 310 state = tokenizeAndHighlight( |
| 310 line, state, offset, trySelection, lineNodes); | 311 line, state, offset, trySelection, lineNodes); |
| 311 offset += line.length; | 312 offset += line.length; |
| 312 nodes.add(makeLine(lineNodes, state)); | 313 nodes.add(makeLine(lineNodes, state)); |
| 313 } | 314 } |
| 314 | 315 |
| 315 node.parent.insertAllBefore(nodes, node); | 316 node.parent.insertAllBefore(nodes, node); |
| 316 node.remove(); | 317 node.remove(); |
| 317 trySelection.adjust(selection); | 318 trySelection.adjust(selection); |
| 318 | 319 |
| 320 // TODO(ahe): We know almost exactly what has changed. It could be |
| 321 // more efficient to only communicate what changed. |
| 322 context.currentCompilationUnit.content = getText(mainEditorPane); |
| 323 |
| 319 // Discard highlighting mutations. | 324 // Discard highlighting mutations. |
| 320 observer.takeRecords(); | 325 observer.takeRecords(); |
| 321 return; | 326 return; |
| 322 } | 327 } |
| 323 } | 328 } |
| 324 | 329 |
| 330 // TODO(ahe): Use getText(mainEditorPane) instead. |
| 325 removeShadowRootPolyfill(mainEditorPane); | 331 removeShadowRootPolyfill(mainEditorPane); |
| 326 | 332 |
| 327 String currentText = mainEditorPane.text; | 333 String currentText = mainEditorPane.text; |
| 328 trySelection.updateText(currentText); | 334 trySelection.updateText(currentText); |
| 329 | 335 |
| 330 context.currentCompilationUnit.content = currentText; | 336 context.currentCompilationUnit.content = currentText; |
| 331 | 337 |
| 332 editor.seenIdentifiers = new Set<String>.from(mock.identifiers); | 338 editor.seenIdentifiers = new Set<String>.from(mock.identifiers); |
| 333 | 339 |
| 334 editor.isMalformedInput = false; | 340 editor.isMalformedInput = false; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 return text.split(new RegExp('^', multiLine: true)); | 897 return text.split(new RegExp('^', multiLine: true)); |
| 892 } | 898 } |
| 893 | 899 |
| 894 void removeCodeCompletion() { | 900 void removeCodeCompletion() { |
| 895 List<Node> highlighting = | 901 List<Node> highlighting = |
| 896 mainEditorPane.querySelectorAll('.dart-code-completion'); | 902 mainEditorPane.querySelectorAll('.dart-code-completion'); |
| 897 for (Element element in highlighting) { | 903 for (Element element in highlighting) { |
| 898 element.remove(); | 904 element.remove(); |
| 899 } | 905 } |
| 900 } | 906 } |
| OLD | NEW |