@@ -27,14 +27,18 @@ private UctModuleLocatorUtil() {
2727 }
2828
2929 /**
30- * Find UCT executable for the specified project.
30+ * Find UCT executable for the specified magento 2 project path .
3131 *
3232 * @param project Project
33+ * @param projectRoot String
3334 *
3435 * @return VirtualFile
3536 */
36- public static @ Nullable VirtualFile locateUctExecutable (final @ NotNull Project project ) {
37- final PsiDirectory uctModuleDir = locateModule (project );
37+ public static @ Nullable VirtualFile locateUctExecutable (
38+ final @ NotNull Project project ,
39+ final @ NotNull String projectRoot
40+ ) {
41+ final PsiDirectory uctModuleDir = locateModule (project , projectRoot );
3842
3943 if (uctModuleDir == null ) {
4044 return null ;
@@ -54,6 +58,7 @@ private UctModuleLocatorUtil() {
5458 * Find UCT module base directory.
5559 *
5660 * @param project Project
61+ * @param projectRoot String
5762 *
5863 * @return PsiDirectory
5964 */
@@ -63,24 +68,27 @@ private UctModuleLocatorUtil() {
6368 "PMD.CyclomaticComplexity" ,
6469 "PMD.AvoidDeeplyNestedIfStmts"
6570 })
66- public static @ Nullable PsiDirectory locateModule (final @ NotNull Project project ) {
67- final String projectBasePath = project .getBasePath ();
68-
69- if (projectBasePath == null ) {
71+ public static @ Nullable PsiDirectory locateModule (
72+ final @ NotNull Project project ,
73+ final @ NotNull String projectRoot
74+ ) {
75+ if (projectRoot .isEmpty ()) {
7076 return null ;
7177 }
72- final VirtualFile projectBaseVf = VfsUtil .findFile (Path .of (projectBasePath ), false );
78+ final VirtualFile magentoProjectBaseVf = VfsUtil .findFile (Path .of (projectRoot ), false );
7379
74- if (projectBaseVf == null ) {
80+ if (magentoProjectBaseVf == null ) {
7581 return null ;
7682 }
7783 final PsiManager psiManager = PsiManager .getInstance (project );
78- final PsiDirectory projectBaseDir = psiManager .findDirectory (projectBaseVf );
84+ final PsiDirectory magentoProjectBaseDir = psiManager .findDirectory (magentoProjectBaseVf );
7985
80- if (projectBaseDir == null ) {
86+ if (magentoProjectBaseDir == null ) {
8187 return null ;
8288 }
83- final PsiFile composerConfigurationFile = projectBaseDir .findFile (ComposerJson .FILE_NAME );
89+ final PsiFile composerConfigurationFile = magentoProjectBaseDir .findFile (
90+ ComposerJson .FILE_NAME
91+ );
8492
8593 if (composerConfigurationFile instanceof JsonFile ) {
8694 final boolean hasUctAsProjectDependency = composerConfigurationFile
@@ -89,15 +97,15 @@ private UctModuleLocatorUtil() {
8997
9098 if (hasUctAsProjectDependency ) {
9199 PsiDirectory uctBaseDir = findSubdirectoryByPath (
92- projectBaseDir ,
100+ magentoProjectBaseDir ,
93101 "vendor" .concat (File .separator )
94102 .concat ("magento" )
95103 .concat (File .separator )
96104 .concat ("module-upgrade-compatibility-tool" )
97105 );
98106 if (uctBaseDir == null ) {
99107 uctBaseDir = findSubdirectoryByPath (
100- projectBaseDir ,
108+ magentoProjectBaseDir ,
101109 "app" .concat (File .separator )
102110 .concat ("code" )
103111 .concat (File .separator )
@@ -110,6 +118,21 @@ private UctModuleLocatorUtil() {
110118 return uctBaseDir ;
111119 }
112120 }
121+ final String projectBasePath = project .getBasePath ();
122+
123+ if (projectBasePath == null ) {
124+ return null ;
125+ }
126+ final VirtualFile projectBaseVf = VfsUtil .findFile (Path .of (projectBasePath ), false );
127+
128+ if (projectBaseVf == null ) {
129+ return null ;
130+ }
131+ final PsiDirectory projectBaseDir = psiManager .findDirectory (projectBaseVf );
132+
133+ if (projectBaseDir == null ) {
134+ return null ;
135+ }
113136
114137 for (final PsiDirectory subDir : projectBaseDir .getSubdirectories ()) {
115138 final PsiFile composerFile = subDir .findFile (ComposerJson .FILE_NAME );
0 commit comments