Skip to content

Commit

Permalink
fix: Bug/RuntimeException during startup of project (#1027)
Browse files Browse the repository at this point in the history
Fixes #1027

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jul 21, 2023
1 parent 387b3de commit 093d7e6
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
* Copyright (c) 2023 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package com.redhat.microprofile.psi.internal.quarkus.renarde.java;

import java.util.Collections;
Expand Down Expand Up @@ -45,17 +45,16 @@ private RenardeUtils() {
*
* @param psiClass the class to check
* @return true if the given class extends Renarde's <code>Controller</code>
* class and false otherwise
* class and false otherwise
*/
public static boolean isControllerClass(@Nullable PsiClass psiClass) {
if (psiClass == null) {
return false;
}
Module project = ModuleUtilCore.findModuleForPsiElement(psiClass);
return isControllerClass(project, psiClass);
return project != null ? isControllerClass(project, psiClass) : false;
}


/**
* Returns true if the given class extends Renarde's <code>Controller</code>
* class and false otherwise.
Expand All @@ -64,7 +63,7 @@ public static boolean isControllerClass(@Nullable PsiClass psiClass) {
* @param typeRoot the class (compilation unit or class file) to check
* @param monitor the progress monitor
* @return true if the given class extends Renarde's <code>Controller</code>
* class and false otherwise
* class and false otherwise
*/
public static boolean isControllerClass(Module project, PsiFile typeRoot, ProgressIndicator monitor) {
PsiClass type = PsiTreeUtil.getChildOfType(typeRoot, PsiClass.class);
Expand All @@ -81,7 +80,7 @@ public static boolean isControllerClass(@NotNull Module project, @Nullable PsiCl
return false;
}
// Check if the current type extends "io.quarkiverse.renarde.Controller".
return type.isInheritor(renardeControllerType,true);
return type.isInheritor(renardeControllerType, true);
}

/**
Expand All @@ -91,7 +90,7 @@ public static boolean isControllerClass(@NotNull Module project, @Nullable PsiCl
* @param project the project to search in
* @param monitor the progress monitor
* @return a set of all classes in the given project that extend Renarde's
* <code>Controller</code> class
* <code>Controller</code> class
*/
public static Set<PsiClass> getAllControllerClasses(Module project, ProgressIndicator monitor) {
// TODO: implement when LSP4IJ will support workspace symbols
Expand Down

0 comments on commit 093d7e6

Please sign in to comment.