mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle: do not wait for virtual file during project import for building of Navigatable object
related issue - IDEA-126275 Gradle MultiProject is not opened on 13.1.4 EAP (IU-135.1019)
(cherry picked from commit 5792e2f)
This commit is contained in:
+41
-3
@@ -27,10 +27,13 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder.*;
|
||||
|
||||
/**
|
||||
@@ -64,9 +67,8 @@ public class GradleProjectImportNotificationListener extends ExternalSystemTaskN
|
||||
NotificationData notification = new NotificationData(
|
||||
group, errorMessage, NotificationCategory.WARNING, NotificationSource.PROJECT_SYNC);
|
||||
|
||||
final VirtualFile virtualFile = ExternalSystemUtil.waitForTheFile(path);
|
||||
if (virtualFile != null) {
|
||||
notification.setNavigatable(new OpenFileDescriptor(project, virtualFile));
|
||||
if (path != null) {
|
||||
notification.setNavigatable(new MyNavigatable(new File(path), project));
|
||||
}
|
||||
|
||||
ExternalSystemNotificationManager.getInstance(project).showNotification(id.getProjectSystemId(), notification);
|
||||
@@ -82,4 +84,40 @@ public class GradleProjectImportNotificationListener extends ExternalSystemTaskN
|
||||
int end = str.indexOf(close, start + open.length());
|
||||
return end != -1 ? str.substring(start + open.length(), end) : null;
|
||||
}
|
||||
|
||||
private static class MyNavigatable implements Navigatable {
|
||||
|
||||
private final @NotNull File myFile;
|
||||
private final @NotNull Project myProject;
|
||||
private volatile OpenFileDescriptor openFileDescriptor;
|
||||
|
||||
public MyNavigatable(@NotNull File file, @NotNull Project project) {
|
||||
myFile = file;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
OpenFileDescriptor fileDescriptor = openFileDescriptor;
|
||||
if (fileDescriptor == null) {
|
||||
final VirtualFile virtualFile = ExternalSystemUtil.waitForTheFile(myFile.getPath());
|
||||
if (virtualFile != null) {
|
||||
openFileDescriptor = fileDescriptor = new OpenFileDescriptor(myProject, virtualFile);
|
||||
}
|
||||
}
|
||||
if (fileDescriptor != null && fileDescriptor.canNavigate()) {
|
||||
fileDescriptor.navigate(requestFocus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return myFile.exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return canNavigate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user