@@ -27,14 +27,18 @@ private UctModuleLocatorUtil() {
27
27
}
28
28
29
29
/**
30
- * Find UCT executable for the specified project.
30
+ * Find UCT executable for the specified magento 2 project path .
31
31
*
32
32
* @param project Project
33
+ * @param projectRoot String
33
34
*
34
35
* @return VirtualFile
35
36
*/
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 );
38
42
39
43
if (uctModuleDir == null ) {
40
44
return null ;
@@ -54,6 +58,7 @@ private UctModuleLocatorUtil() {
54
58
* Find UCT module base directory.
55
59
*
56
60
* @param project Project
61
+ * @param projectRoot String
57
62
*
58
63
* @return PsiDirectory
59
64
*/
@@ -63,24 +68,27 @@ private UctModuleLocatorUtil() {
63
68
"PMD.CyclomaticComplexity" ,
64
69
"PMD.AvoidDeeplyNestedIfStmts"
65
70
})
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 ()) {
70
76
return null ;
71
77
}
72
- final VirtualFile projectBaseVf = VfsUtil .findFile (Path .of (projectBasePath ), false );
78
+ final VirtualFile magentoProjectBaseVf = VfsUtil .findFile (Path .of (projectRoot ), false );
73
79
74
- if (projectBaseVf == null ) {
80
+ if (magentoProjectBaseVf == null ) {
75
81
return null ;
76
82
}
77
83
final PsiManager psiManager = PsiManager .getInstance (project );
78
- final PsiDirectory projectBaseDir = psiManager .findDirectory (projectBaseVf );
84
+ final PsiDirectory magentoProjectBaseDir = psiManager .findDirectory (magentoProjectBaseVf );
79
85
80
- if (projectBaseDir == null ) {
86
+ if (magentoProjectBaseDir == null ) {
81
87
return null ;
82
88
}
83
- final PsiFile composerConfigurationFile = projectBaseDir .findFile (ComposerJson .FILE_NAME );
89
+ final PsiFile composerConfigurationFile = magentoProjectBaseDir .findFile (
90
+ ComposerJson .FILE_NAME
91
+ );
84
92
85
93
if (composerConfigurationFile instanceof JsonFile ) {
86
94
final boolean hasUctAsProjectDependency = composerConfigurationFile
@@ -89,15 +97,15 @@ private UctModuleLocatorUtil() {
89
97
90
98
if (hasUctAsProjectDependency ) {
91
99
PsiDirectory uctBaseDir = findSubdirectoryByPath (
92
- projectBaseDir ,
100
+ magentoProjectBaseDir ,
93
101
"vendor" .concat (File .separator )
94
102
.concat ("magento" )
95
103
.concat (File .separator )
96
104
.concat ("module-upgrade-compatibility-tool" )
97
105
);
98
106
if (uctBaseDir == null ) {
99
107
uctBaseDir = findSubdirectoryByPath (
100
- projectBaseDir ,
108
+ magentoProjectBaseDir ,
101
109
"app" .concat (File .separator )
102
110
.concat ("code" )
103
111
.concat (File .separator )
@@ -110,6 +118,21 @@ private UctModuleLocatorUtil() {
110
118
return uctBaseDir ;
111
119
}
112
120
}
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
+ }
113
136
114
137
for (final PsiDirectory subDir : projectBaseDir .getSubdirectories ()) {
115
138
final PsiFile composerFile = subDir .findFile (ComposerJson .FILE_NAME );
0 commit comments