OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 function SetScriptSource(script, new_source, preview_only, change_log) { | 981 function SetScriptSource(script, new_source, preview_only, change_log) { |
982 var old_source = script.source; | 982 var old_source = script.source; |
983 var diff = CompareStrings(old_source, new_source); | 983 var diff = CompareStrings(old_source, new_source); |
984 return ApplyPatchMultiChunk(script, diff, new_source, preview_only, | 984 return ApplyPatchMultiChunk(script, diff, new_source, preview_only, |
985 change_log); | 985 change_log); |
986 } | 986 } |
987 // Function is public. | 987 // Function is public. |
988 this.SetScriptSource = SetScriptSource; | 988 this.SetScriptSource = SetScriptSource; |
989 | 989 |
990 function CompareStrings(s1, s2) { | 990 function CompareStrings(s1, s2) { |
991 return %LiveEditCompareStrings(s1, s2); | 991 try { |
| 992 return %LiveEditCompareStrings(s1, s2); |
| 993 } catch (e) { |
| 994 throw new Failure("Failed to calculate text difference: " + String(e)); |
| 995 } |
992 } | 996 } |
993 | 997 |
994 // Applies the change to the script. | 998 // Applies the change to the script. |
995 // The change is always a substring (change_pos, change_pos + change_len) | 999 // The change is always a substring (change_pos, change_pos + change_len) |
996 // being replaced with a completely different string new_str. | 1000 // being replaced with a completely different string new_str. |
997 // This API is a legacy and is obsolete. | 1001 // This API is a legacy and is obsolete. |
998 // | 1002 // |
999 // @param {Script} script that is being changed | 1003 // @param {Script} script that is being changed |
1000 // @param {Array} change_log a list that collects engineer-readable | 1004 // @param {Array} change_log a list that collects engineer-readable |
1001 // description of what happened. | 1005 // description of what happened. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 } | 1077 } |
1074 | 1078 |
1075 | 1079 |
1076 // Functions are public for tests. | 1080 // Functions are public for tests. |
1077 this.TestApi = { | 1081 this.TestApi = { |
1078 PosTranslator: PosTranslator, | 1082 PosTranslator: PosTranslator, |
1079 CompareStrings: CompareStrings, | 1083 CompareStrings: CompareStrings, |
1080 ApplySingleChunkPatch: ApplySingleChunkPatch | 1084 ApplySingleChunkPatch: ApplySingleChunkPatch |
1081 } | 1085 } |
1082 } | 1086 } |
OLD | NEW |