Просмотр исходного кода

Kernel name to setHashParameters

krzysztof.sikora 4 лет назад
Родитель
Сommit
fdb4e0331f
2 измененных файлов с 21 добавлено и 8 удалено
  1. 16 7
      src/debugger-configuration.ts
  2. 5 1
      src/service.ts

+ 16 - 7
src/debugger-configuration.ts

@@ -46,14 +46,23 @@ export class DebuggerConfiguration implements IDebuggerConfig {
    *
    * @param method The hash method.
    * @param seed The seed for the hash method.
+   * @param kernelName Kernel name for algorithm selection
    */
-  public setHashParameters(method: string, seed: number): void {
-    if (method === 'Murmur2') {
-      this._hashMethod = (code: string): string => {
-        return murmur2(code, seed).toString();
-      };
+  public setHashParameters(
+    method: string,
+    seed: number,
+    kernelName: string
+  ): void {
+    if (kernelName === 'xpython') {
+      if (method === 'Murmur2') {
+        this._hashMethod = (code: string): string => {
+          return murmur2(code, seed).toString();
+        };
+      } else {
+        throw new Error('hash method not supported ' + method);
+      }
     } else {
-      throw new Error('hash method not supported ' + method);
+      throw new Error('Kernel not supported ' + kernelName);
     }
   }
 
@@ -83,7 +92,7 @@ export const IDebuggerConfig = new Token<IDebuggerConfig>(
  * Interface for configuration plugin
  */
 export interface IDebuggerConfig {
-  setHashParameters(method: string, seed: number): void;
+  setHashParameters(method: string, seed: number, kernelName: string): void;
   setTmpFileParameters(
     prefix: string,
     suffix: string,

+ 5 - 1
src/service.ts

@@ -232,7 +232,11 @@ export class DebuggerService implements IDebugger, IDisposable {
     const stoppedThreads = new Set(reply.body.stoppedThreads);
     const kernelName = this.session.connection.kernel.name;
 
-    this._debuggerConfiguration.setHashParameters(hashMethod, hashSeed);
+    this._debuggerConfiguration.setHashParameters(
+      hashMethod,
+      hashSeed,
+      kernelName
+    );
     this._debuggerConfiguration.setTmpFileParameters(
       tmpFilePrefix,
       tmpFileSuffix,