Skip to content

Commit

Permalink
fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Jul 13, 2023
1 parent 5bc14af commit 308dd6d
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
Expand All @@ -31,6 +32,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -67,11 +69,10 @@ public PsiElement getDocumentationElementForLink(@NotNull PsiManager psiManager,
Matcher linkMatcher = PATTERN_PSI_LINK.matcher(link);
if (linkMatcher.matches()) {
String moduleName = linkMatcher.group(1);
PsiFile[] psiFiles = FilenameIndex.getFilesByName(
project, moduleName + ".erl", GlobalSearchScope.allScope(project));
for (PsiFile psiFile : psiFiles) {
if (psiFile instanceof ErlangFile) {
ErlangFile erlFile = (ErlangFile) psiFile;
@NotNull Collection<VirtualFile> vFiles = FilenameIndex.getVirtualFilesByName(moduleName + ".erl", GlobalSearchScope.allScope(project));
for (VirtualFile vFile : vFiles) {
PsiFile psiFile = psiManager.findFile(vFile);
if (psiFile instanceof ErlangFile erlFile) {
if (linkMatcher.group(2) == null) {
return erlFile.getModule();
}
Expand All @@ -94,9 +95,9 @@ public PsiElement getDocumentationElementForLink(@NotNull PsiManager psiManager,

@Nullable
@Override
public String fetchExternalDocumentation(Project project, final PsiElement element, List<String> docUrls) {
ErlangSdkDocProviderBase externalDocProvider =
ApplicationManager.getApplication().runReadAction((Computable<ErlangSdkDocProviderBase>) () -> ObjectUtils.tryCast(ElementDocProviderFactory.create(element), ErlangSdkDocProviderBase.class));
public String fetchExternalDocumentation(Project project, final PsiElement element, List<String> docUrls, boolean onHover) {
ErlangSdkDocProviderBase externalDocProvider = ApplicationManager.getApplication().runReadAction((Computable<ErlangSdkDocProviderBase>) () ->
ObjectUtils.tryCast(ElementDocProviderFactory.create(element), ErlangSdkDocProviderBase.class));
return externalDocProvider != null ? externalDocProvider.getDocText() : null;
}

Expand Down

0 comments on commit 308dd6d

Please sign in to comment.