From 9a19bb2b8e3422eda46703a4f54d557db87529e9 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 9 Feb 2015 12:22:03 +0100 Subject: [PATCH] =?UTF-8?q?move=20FileUrlMapper=20to=20community=20?= =?UTF-8?q?=E2=80=94=20kotlin=20should=20be=20able=20to=20use=20this=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascript/debugger/FileUrlMapper.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/FileUrlMapper.java diff --git a/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/FileUrlMapper.java b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/FileUrlMapper.java new file mode 100644 index 000000000000..b079afcddcd1 --- /dev/null +++ b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/FileUrlMapper.java @@ -0,0 +1,54 @@ +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.List; + +public abstract class FileUrlMapper { + public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.jetbrains.fileUrlMapper"); + + @NotNull + public abstract List getUrls(@NotNull VirtualFile file, @NotNull Project project, @Nullable String currentAuthority); + + /** + * 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 map, @NotNull Project project); + } +} \ No newline at end of file