mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-162765 Do not display "target JRE version does not match project JDK version" alert when project SDK differs from module SDK
This commit is contained in:
@@ -42,6 +42,11 @@ public interface DebugEnvironment {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default Sdk getRunJre() {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isRemote();
|
||||
|
||||
RemoteConnection getRemoteConnection();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -96,4 +97,17 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
|
||||
public Sdk getAlternativeJre() {
|
||||
return AlternativeJreClassFinder.getAlternativeJre(environment.getRunProfile());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Sdk getRunJre() {
|
||||
if (state instanceof JavaCommandLine) {
|
||||
try {
|
||||
return ((JavaCommandLine)state).getJavaParameters().getJdk();
|
||||
}
|
||||
catch (ExecutionException ignore) {
|
||||
}
|
||||
}
|
||||
return ProjectRootManager.getInstance(environment.getProject()).getProjectSdk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -608,15 +607,15 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
));
|
||||
}
|
||||
if (getSession().getAlternativeJre() == null) {
|
||||
Sdk projectSdk = ProjectRootManager.getInstance(myProject).getProjectSdk();
|
||||
if ((projectSdk == null || projectSdk.getSdkType() instanceof JavaSdkType) && !versionMatch(projectSdk, version)) {
|
||||
Sdk runjre = getSession().getRunJre();
|
||||
if ((runjre == null || runjre.getSdkType() instanceof JavaSdkType) && !versionMatch(runjre, version)) {
|
||||
Arrays.stream(ProjectJdkTable.getInstance().getAllJdks())
|
||||
.filter(sdk -> versionMatch(sdk, version))
|
||||
.findFirst().ifPresent(sdk -> {
|
||||
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(
|
||||
DebuggerBundle.message("message.remote.jre.version.mismatch",
|
||||
version,
|
||||
projectSdk != null ? projectSdk.getVersionString() : "unknown",
|
||||
runjre != null ? runjre.getVersionString() : "unknown",
|
||||
sdk.getName())
|
||||
, MessageType.INFO).notify(myProject);
|
||||
getSession().setAlternativeJre(sdk);
|
||||
|
||||
@@ -94,6 +94,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
private final DebugProcessImpl myDebugProcess;
|
||||
private final GlobalSearchScope mySearchScope;
|
||||
private Sdk myAlternativeJre;
|
||||
private Sdk myRunJre;
|
||||
|
||||
private final DebuggerContextImpl SESSION_EMPTY_CONTEXT;
|
||||
//Thread, user is currently stepping through
|
||||
@@ -129,6 +130,10 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
Extensions.findExtension(PsiElementFinder.EP_NAME, getProject(), AlternativeJreClassFinder.class).clearCache();
|
||||
}
|
||||
|
||||
public Sdk getRunJre() {
|
||||
return myRunJre;
|
||||
}
|
||||
|
||||
public boolean isModifiedClassesScanRequired() {
|
||||
return myModifiedClassesScanRequired;
|
||||
}
|
||||
@@ -220,6 +225,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
ValueLookupManager.getInstance(getProject()).startListening();
|
||||
mySearchScope = environment.getSearchScope();
|
||||
myAlternativeJre = environment.getAlternativeJre();
|
||||
myRunJre = environment.getRunJre();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user