Skip to content

Commit

Permalink
fix: Modification to replace the usage of deprecated method DumbServi…
Browse files Browse the repository at this point in the history
…ce.runReadActionInSmartMode(Computable) (redhat-developer#1421)

fix: Modification to replace the usage of deprecated method DumbService.runReadActionInSmartMode(Computable)

Fixes redhat-developer#1420
  • Loading branch information
dessina-devasia authored Jan 11, 2025
1 parent 8e1a98e commit efc6c6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019-2020 Red Hat Inc. and others.
* Copyright (c) 2019-2025 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
Expand All @@ -11,13 +11,10 @@
*******************************************************************************/
package com.redhat.devtools.intellij.lsp4mp4ij.psi.core;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.utils.IPsiUtils;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.internal.core.ls.PsiUtilsLSImpl;
Expand Down Expand Up @@ -97,7 +94,7 @@ public ProjectLabelInfoEntry getProjectLabelInfo(MicroProfileJavaProjectLabelsPa
if (module == null) {
return ProjectLabelInfoEntry.EMPTY_PROJECT_INFO;
}
return DumbService.getInstance(module.getProject()).runReadActionInSmartMode(() -> getProjectLabelInfo(module, params.getTypes(), utils));
return getProjectLabelInfo(module, params.getTypes(), utils);
} catch (IOException e) {
return ProjectLabelInfoEntry.EMPTY_PROJECT_INFO;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2019-2025 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,
Expand All @@ -10,12 +10,8 @@
******************************************************************************/
package com.redhat.devtools.intellij.lsp4mp4ij.psi.core;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
Expand Down Expand Up @@ -222,20 +218,18 @@ public Location findPropertyLocation(VirtualFile file, String sourceType, String
}

public Location findPropertyLocation(Module module, String sourceType, String sourceField, String sourceMethod, IPsiUtils utils) {
return DumbService.getInstance(module.getProject()).runReadActionInSmartMode(() -> {
PsiMember fieldOrMethod = findDeclaredProperty(module, sourceType, sourceField, sourceMethod, utils);
if (fieldOrMethod != null) {
PsiFile classFile = fieldOrMethod.getContainingFile();
if (classFile != null) {
// Try to download source if required
if (utils != null) {
utils.discoverSource(classFile);
}
PsiMember fieldOrMethod = findDeclaredProperty(module, sourceType, sourceField, sourceMethod, utils);
if (fieldOrMethod != null) {
PsiFile classFile = fieldOrMethod.getContainingFile();
if (classFile != null) {
// Try to download source if required
if (utils != null) {
utils.discoverSource(classFile);
}
return utils.toLocation(fieldOrMethod);
}
return null;
});
return utils.toLocation(fieldOrMethod);
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Red Hat, Inc.
* Copyright (c) 2020-2025 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,
Expand All @@ -11,14 +11,10 @@
package com.redhat.devtools.intellij.lsp4mp4ij.psi.core;

import com.intellij.lang.jvm.JvmParameter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
Expand Down

0 comments on commit efc6c6a

Please sign in to comment.