| OLD | NEW |
| 1 package org.chromium.sdk.internal.v8native; | 1 package org.chromium.sdk.internal.v8native; |
| 2 | 2 |
| 3 import java.util.Collections; | 3 import java.util.Collections; |
| 4 import java.util.logging.Level; | 4 import java.util.logging.Level; |
| 5 import java.util.logging.Logger; | 5 import java.util.logging.Logger; |
| 6 | 6 |
| 7 import org.chromium.sdk.DebugContext; | 7 import org.chromium.sdk.DebugContext; |
| 8 import org.chromium.sdk.DebugEventListener; | 8 import org.chromium.sdk.DebugEventListener; |
| 9 import org.chromium.sdk.RelayOk; | 9 import org.chromium.sdk.RelayOk; |
| 10 import org.chromium.sdk.SyncCallback; | 10 import org.chromium.sdk.SyncCallback; |
| 11 import org.chromium.sdk.TextStreamPosition; |
| 12 import org.chromium.sdk.UpdatableScript; |
| 11 import org.chromium.sdk.internal.ScriptBase; | 13 import org.chromium.sdk.internal.ScriptBase; |
| 12 import org.chromium.sdk.internal.liveeditprotocol.LiveEditResult; | 14 import org.chromium.sdk.internal.liveeditprotocol.LiveEditResult; |
| 13 import org.chromium.sdk.internal.protocolparser.JsonProtocolParseException; | 15 import org.chromium.sdk.internal.protocolparser.JsonProtocolParseException; |
| 14 import org.chromium.sdk.internal.v8native.V8Helper.ScriptLoadCallback; | 16 import org.chromium.sdk.internal.v8native.V8Helper.ScriptLoadCallback; |
| 15 import org.chromium.sdk.internal.v8native.protocol.input.ChangeLiveBody; | 17 import org.chromium.sdk.internal.v8native.protocol.input.ChangeLiveBody; |
| 16 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse.E
rrorDetails; | 18 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse.E
rrorDetails; |
| 17 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; | 19 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; |
| 18 import org.chromium.sdk.internal.v8native.protocol.input.data.ScriptHandle; | 20 import org.chromium.sdk.internal.v8native.protocol.input.data.ScriptHandle; |
| 19 import org.chromium.sdk.internal.v8native.protocol.input.data.SomeHandle; | 21 import org.chromium.sdk.internal.v8native.protocol.input.data.SomeHandle; |
| 20 import org.chromium.sdk.internal.v8native.protocol.output.ChangeLiveMessage; | 22 import org.chromium.sdk.internal.v8native.protocol.output.ChangeLiveMessage; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 97 } |
| 96 | 98 |
| 97 if (callback != null) { | 99 if (callback != null) { |
| 98 callback.success(body.getChangeLog(), | 100 callback.success(body.getChangeLog(), |
| 99 UpdateResultParser.wrapChangeDescription(resultDescription)); | 101 UpdateResultParser.wrapChangeDescription(resultDescription)); |
| 100 } | 102 } |
| 101 } | 103 } |
| 102 | 104 |
| 103 @Override | 105 @Override |
| 104 public void failure(String message, ErrorDetails errorDetails) { | 106 public void failure(String message, ErrorDetails errorDetails) { |
| 105 callback.failure(message); | 107 UpdatableScript.Failure failure; |
| 108 if (errorDetails == null) { |
| 109 failure = UpdatableScript.Failure.UNSPECIFIED; |
| 110 } else if (errorDetails.asChangeLiveCompileError() != null) { |
| 111 final ChangeLiveBody.CompileErrorDetails compileErrorDetails = |
| 112 errorDetails.asChangeLiveCompileError(); |
| 113 failure = new UpdatableScript.CompileErrorFailure() { |
| 114 @Override public <R> R accept(Visitor<R> visitor) { |
| 115 return visitor.visitCompileError(this); |
| 116 } |
| 117 |
| 118 @Override |
| 119 public TextStreamPosition getStartPosition() { |
| 120 ChangeLiveBody.CompileErrorDetails.PositionRange position = |
| 121 compileErrorDetails.position(); |
| 122 if (position == null) { |
| 123 return null; |
| 124 } |
| 125 return wrapJson(position.start()); |
| 126 } |
| 127 |
| 128 @Override |
| 129 public TextStreamPosition getEndPosition() { |
| 130 ChangeLiveBody.CompileErrorDetails.PositionRange position = |
| 131 compileErrorDetails.position(); |
| 132 if (position == null) { |
| 133 return null; |
| 134 } |
| 135 return wrapJson(position.end()); |
| 136 } |
| 137 |
| 138 @Override |
| 139 public String getCompilerMessage() { |
| 140 return compileErrorDetails.syntaxErrorMessage(); |
| 141 } |
| 142 |
| 143 private TextStreamPosition wrapJson( |
| 144 final ChangeLiveBody.CompileErrorDetails.Position pointPosition)
{ |
| 145 return new TextStreamPosition() { |
| 146 @Override public int getOffset() { |
| 147 return (int) pointPosition.position(); |
| 148 } |
| 149 @Override public int getLine() { |
| 150 return (int) pointPosition.line(); |
| 151 } |
| 152 @Override public int getColumn() { |
| 153 return (int) pointPosition.column(); |
| 154 } |
| 155 }; |
| 156 } |
| 157 }; |
| 158 } else { |
| 159 failure = UpdatableScript.Failure.UNSPECIFIED; |
| 160 } |
| 161 callback.failure(message, failure); |
| 106 } | 162 } |
| 107 }; | 163 }; |
| 108 } | 164 } |
| 109 | 165 |
| 110 public static Long getScriptId(HandleManager handleManager, long scriptRef) { | 166 public static Long getScriptId(HandleManager handleManager, long scriptRef) { |
| 111 SomeHandle handle = handleManager.getHandle(scriptRef); | 167 SomeHandle handle = handleManager.getHandle(scriptRef); |
| 112 if (handle == null) { | 168 if (handle == null) { |
| 113 return -1L; // not found | 169 return -1L; // not found |
| 114 } | 170 } |
| 115 ScriptHandle scriptHandle; | 171 ScriptHandle scriptHandle; |
| 116 try { | 172 try { |
| 117 scriptHandle = handle.asScriptHandle(); | 173 scriptHandle = handle.asScriptHandle(); |
| 118 } catch (JsonProtocolParseException e) { | 174 } catch (JsonProtocolParseException e) { |
| 119 throw new RuntimeException(e); | 175 throw new RuntimeException(e); |
| 120 } | 176 } |
| 121 return scriptHandle.id(); | 177 return scriptHandle.id(); |
| 122 } | 178 } |
| 123 } | 179 } |
| OLD | NEW |