Skip to content

Commit

Permalink
fix: java.lang.IllegalArgumentException: Argument for @NotNull parameter
Browse files Browse the repository at this point in the history
'project' of com/intellij/execution/ui/RunContentManager.getInstance
must not be null

Fixes #1379

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Aug 30, 2024
1 parent bb9c0ce commit 24c0d8e
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.redhat.devtools.intellij.lsp4mp4ij.classpath.ClasspathResourceChangedManager;
import com.redhat.devtools.intellij.quarkus.QuarkusPluginDisposable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Set;

Expand Down Expand Up @@ -61,7 +62,7 @@ public void sourceFilesChanged(Set<Pair<VirtualFile, Module>> sources) {
if (isConfigSource(file)) {
// A microprofile config file properties file source has been updated, evict the cache of the properties
Module javaProject = pair.getSecond();
PsiMicroProfileProject mpProject = getMicroProfileProject(javaProject);
PsiMicroProfileProject mpProject = getMicroProfileProject(javaProject, false);
if (mpProject != null) {
mpProject.evictConfigSourcesCache(file);
}
Expand Down Expand Up @@ -90,11 +91,13 @@ private PsiMicroProfileProjectManager(Project project) {
connection.subscribe(ProjectTopics.MODULES, microprofileProjectListener);
}

public PsiMicroProfileProject getMicroProfileProject(Module project) {
@NotNull
public PsiMicroProfileProject getMicroProfileProject(@NotNull Module project) {
return getMicroProfileProject(project, true);
}

private PsiMicroProfileProject getMicroProfileProject(Module javaProject, boolean create) {
@Nullable
private PsiMicroProfileProject getMicroProfileProject(@NotNull Module javaProject, boolean create) {
PsiMicroProfileProject mpProject = javaProject.getUserData(KEY);
if (mpProject == null) {
if (!create) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ public class QuarkusConstants {

public static final String QUARKUS_RUNTIME_CLASS_NAME = "io.quarkus.runtime.LaunchMode";
public static final String QUARKUS_BUILD_ITEM_CLASS_NAME = "io.quarkus.builder.item.BuildItem";
public static final String QUARKUS_RUN_CONTEXT_KEY = QuarkusConstants.class.getName() + ".quarkusContext";

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.project.PsiMicroProfileProject;
import com.redhat.devtools.lsp4ij.LSPIJUtils;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.internal.core.ls.PsiUtilsLSImpl;
import com.redhat.devtools.intellij.quarkus.facet.QuarkusFacet;
Expand All @@ -37,6 +38,7 @@
import java.util.regex.Pattern;

public class QuarkusModuleUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(QuarkusModuleUtil.class);

private static final Pattern QUARKUS_CORE_PATTERN = Pattern.compile("quarkus-core-(\\d[a-zA-Z\\d-.]+?).jar");
Expand Down Expand Up @@ -180,4 +182,36 @@ public static void sortRoot(List<VirtualFile> roots) {
public static void sortRoot(VirtualFile[] roots) {
Arrays.sort(roots, ROOT_COMPARATOR); // put root with smallest path first (eliminates generated sources roots)
}

public static String getApplicationUrl(@NotNull PsiMicroProfileProject mpProject) {
int port = getPort(mpProject);
String path = mpProject.getProperty("quarkus.http.root-path", "/");
return "http://localhost:" + port + normalize(path);
}

public static String getDevUIUrl(@NotNull PsiMicroProfileProject mpProject) {
int port = getPort(mpProject);
String path = mpProject.getProperty("quarkus.http.non-application-root-path", "q");
if (!path.startsWith("/")) {
String rootPath = mpProject.getProperty("quarkus.http.root-path", "/");
path = normalize(rootPath) + path;
}
return "http://localhost:" + port + normalize(path) + "dev";
}

private static String normalize(String path) {
StringBuilder builder = new StringBuilder(path);
if (builder.isEmpty() || builder.charAt(0) != '/') {
builder.insert(0, '/');
}
if (builder.charAt(builder.length() - 1) != '/') {
builder.append('/');
}
return builder.toString();
}

private static int getPort(@NotNull PsiMicroProfileProject mpProject) {
int port = mpProject.getPropertyAsInteger("quarkus.http.port", 8080);
return mpProject.getPropertyAsInteger("%dev.quarkus.http.port", port);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 24c0d8e

Please sign in to comment.