forked from redhat-developer/lsp4ij
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes redhat-developer#376 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
6f183e1
commit f4a19c9
Showing
14 changed files
with
606 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...n/java/com/redhat/devtools/lsp4ij/features/documentation/LSPDocumentationLinkHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package com.redhat.devtools.lsp4ij.features.documentation; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.platform.backend.documentation.DocumentationLinkHandler; | ||
import com.intellij.platform.backend.documentation.DocumentationTarget; | ||
import com.intellij.platform.backend.documentation.LinkResolveResult; | ||
import com.redhat.devtools.lsp4ij.LSPIJUtils; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* LSP {@link DocumentationLinkHandler} to open file in an | ||
* IJ Editor (and with a given position if declared) declared as link in HTML. | ||
*/ | ||
@ApiStatus.Internal | ||
public class LSPDocumentationLinkHandler implements DocumentationLinkHandler { | ||
|
||
@Override | ||
public @Nullable LinkResolveResult resolveLink(@NotNull DocumentationTarget target, | ||
@NotNull String url) { | ||
if (target instanceof LSPDocumentationTarget lspTarget) { | ||
if (url.startsWith("file://")) { | ||
ApplicationManager.getApplication() | ||
.executeOnPooledThread(() -> { | ||
var file = lspTarget.getFile(); | ||
LSPIJUtils.openInEditor(url, null, true, true, file.getProject()); | ||
}); | ||
return LinkResolveResult.resolvedTarget(target); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.