11package io .github .linyimin .plugin .compile ;
22
3- import com .intellij .compiler .impl .ModuleCompileScope ;
3+ import com .intellij .compiler .impl .ProjectCompileScope ;
44import com .intellij .openapi .compiler .CompilerManager ;
5- import com .intellij .openapi .module .Module ;
6- import com .intellij .openapi .module .ModuleUtilCore ;
75import com .intellij .openapi .project .Project ;
86import com .intellij .openapi .roots .OrderEnumerator ;
97import com .intellij .openapi .ui .Messages ;
108import com .intellij .openapi .util .io .FileUtil ;
11- import com .intellij .openapi .vfs .VirtualFile ;
12- import com .intellij .psi .PsiClass ;
13- import com .intellij .psi .PsiMethod ;
14- import com .intellij .psi .util .ClassUtil ;
159import com .intellij .util .lang .UrlClassLoader ;
16- import io .github .linyimin .plugin .service .MybatisSqlStateComponent ;
17- import io .github .linyimin .plugin .service .model .MybatisSqlConfiguration ;
18- import io .github .linyimin .plugin .utils .JavaUtils ;
19- import org .apache .commons .lang3 .StringUtils ;
2010
2111import java .io .File ;
2212import java .net .MalformedURLException ;
@@ -37,26 +27,16 @@ public class MybatisPojoCompile {
3727
3828 public static void compile (Project project ) {
3929
40- MybatisSqlConfiguration sqlConfig = project .getService (MybatisSqlStateComponent .class ).getState ();
41- assert sqlConfig != null ;
42-
43- String methodName = sqlConfig .getMethod ();
44- String clazzName = StringUtils .substring (methodName ,0 , StringUtils .lastIndexOf (methodName , "." ));
45-
46- PsiClass psiClass = JavaUtils .findClazz (project , clazzName );
47- final Module module = ModuleUtilCore .findModuleForPsiElement (psiClass );
48- final VirtualFile virtualFile = psiClass .getContainingFile ().getVirtualFile ();
49- ModuleCompileScope scope = new ModuleCompileScope (project , new Module []{module }, false );
50- // new FileSetCompileScope(Collections.singletonList(virtualFile), new Module[]{module})
30+ ProjectCompileScope scope = new ProjectCompileScope (project );
5131
5232 CompilerManager .getInstance (project ).make (scope , null );
5333
54- setClassLoader (module );
34+ setClassLoader (project );
5535 }
5636
57- public static void setClassLoader (Module module ) {
37+ public static void setClassLoader (Project project ) {
5838 final List <URL > urls = new ArrayList <>();
59- final List <String > list = OrderEnumerator .orderEntries (module ).recursively ().runtimeOnly ().getPathsList ().getPathList ();
39+ final List <String > list = OrderEnumerator .orderEntries (project ).recursively ().runtimeOnly ().getPathsList ().getPathList ();
6040 for (String path : list ) {
6141 try {
6242 urls .add (new File (FileUtil .toSystemIndependentName (path )).toURI ().toURL ());
0 commit comments