package com.jetbrains.javascript.debugger;

import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.util.Url;
import com.intellij.util.containers.ObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.List;

public abstract class FileUrlMapper {
  public static final ExtensionPointName<FileUrlMapper> EP_NAME = ExtensionPointName.create("com.jetbrains.fileUrlMapper");

  @NotNull
  public List<Url> getUrls(@NotNull VirtualFile file, @NotNull Project project, @Nullable String currentAuthority) {
    return Collections.emptyList();
  }

  /**
   * Optional to implement, useful if default navigation position to source file is not equals to 0:0 (java file for example)
   */
  @Nullable
  public Navigatable getNavigatable(@NotNull Url url, @NotNull Project project, @Nullable Url requestor) {
    VirtualFile file = getFile(url, project, requestor);
    return file == null ? null : new OpenFileDescriptor(project, file);
  }

  @Nullable
  public abstract VirtualFile getFile(@NotNull Url url, @NotNull Project project, @Nullable Url requestor);

  /**
   * Optional to implement, sometimes you cannot build URL, but can match.
   * Lifetime: resolve session lifetime. Could be called multiple times: n <= total sourcemap count
   */
  @Nullable
  public SourceResolver createSourceResolver(@NotNull VirtualFile file, @NotNull Project project) {
    return null;
  }

  @Nullable
  public FileType getFileType(@NotNull Url url) {
    return null;
  }

  public static abstract class SourceResolver {
    /**
     * Return -1 if no match
     */
    public abstract int resolve(@NotNull ObjectIntHashMap<Url> map, @NotNull Project project);
  }
}
@@ -34,17 +34,16 @@
 debugger
-;
 %0A%0Aimport
@@ -93,17 +93,16 @@
 ointName
-;
 %0Aimport 
@@ -151,17 +151,16 @@
 scriptor
-;
 %0Aimport 
@@ -198,17 +198,16 @@
 FileType
-;
 %0Aimport 
@@ -242,17 +242,16 @@
 .Project
-;
 %0Aimport 
@@ -286,17 +286,16 @@
 tualFile
-;
 %0Aimport 
@@ -322,17 +322,16 @@
 igatable
-;
 %0Aimport 
@@ -351,17 +351,16 @@
 util.Url
-;
 %0Aimport 
@@ -408,243 +408,69 @@
 hMap
-;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0A%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Apublic abstract class FileUrlMapper %7B%0A  public static final ExtensionPointName%3CFileUrlMapper%3E
+%0A%0Aabstract class FileUrlMapper %7B%0A  companion object %7B%0A    val
  EP_
@@ -501,16 +501,31 @@
 e.create
+%3CFileUrlMapper%3E
 (%22com.je
@@ -551,40 +551,24 @@
 er%22)
-;%0A
 %0A  
-@NotNull%0A  public List%3CUrl%3E
+%7D%0A%0A  open fun
  get
@@ -572,24 +572,21 @@
 getUrls(
-@NotNull
+file:
  Virtual
@@ -593,41 +593,28 @@
 File
- file, @NotNull P
+, p
 roject
- p
+: P
 roject, 
 @Nul
@@ -613,68 +613,48 @@
 ct, 
-@Nullable String currentAuthority) %7B%0A    return Collections.
+currentAuthority: String?): List%3CUrl%3E = 
 empt
@@ -660,21 +660,16 @@
 tyList()
-;%0A  %7D
 %0A%0A  /**%0A
@@ -806,98 +806,60 @@
 /%0A  
-@Nullable%0A  public Navigatable getNavigatable(@NotNull Url url, @NotNull P
+open fun getNavigatable(url: Url, p
 roject
- p
+: P
 roject, 
 @Nul
@@ -858,55 +858,38 @@
 ct, 
-@Nullable Url requestor) %7B%0A    VirtualFile fi
+requestor: Url?): Navigatab
 le
+?
  = g
@@ -923,181 +923,102 @@
 tor)
-;%0A    return file == null ? null : new OpenFileDescriptor(project, file);%0A  %7D%0A%0A  @Nullable%0A  public abstract VirtualFile getFile(@NotNull Url url, @NotNull P
+?.let %7B OpenFileDescriptor(project, it) %7D%0A%0A  abstract fun getFile(url: Url, p
 roject
- p
+: P
 roject, 
 @Nul
@@ -1017,33 +1017,38 @@
 ct, 
-@Nullable Url requestor);
+requestor: Url?): VirtualFile?
 %0A%0A  
@@ -1238,41 +1238,16 @@
 /%0A  
-@Nullable%0A  public SourceResolver
+open fun
  cre
@@ -1264,24 +1264,21 @@
 esolver(
-@NotNull
+file:
  Virtual
@@ -1285,180 +1285,143 @@
 File
- file, @NotNull P
+, p
 roject
- p
+: P
 roject)
- %7B%0A    return null;%0A  %7D%0A%0A  @Nullable%0A  public FileType getFileType(@NotNull Url url) %7B%0A    return null;%0A  %7D%0A%0A  public static abstract class 
+: FileUrlMapperSourceResolver? = null%0A%0A  open fun getFileType(url: Url): FileType? = null%0A%7D%0A%0Ainterface FileUrlMapper
 Sour
@@ -1437,18 +1437,14 @@
 r %7B%0A
-  
   /**%0A
-  
    *
@@ -1473,36 +1473,16 @@
 %0A   
-  
 */%0A  
-  public abstract int
+fun
  res
@@ -1486,24 +1486,20 @@
 resolve(
-@NotNull
+map:
  ObjectI
@@ -1516,42 +1516,30 @@
 Url%3E
- map, @NotNull P
+, p
 roject
- p
+: P
 roject)
-;%0A  %7D
+: Int
 %0A%7D

convert FileUrlMapper to kotlin