From d26e777981753d769aa94c3de96a2799674c81a6 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Thu, 1 Dec 2022 16:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmodule=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/sjhy/plugin/tool/ModuleUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/sjhy/plugin/tool/ModuleUtils.java b/src/main/java/com/sjhy/plugin/tool/ModuleUtils.java index ac21dbd..4a41cb8 100644 --- a/src/main/java/com/sjhy/plugin/tool/ModuleUtils.java +++ b/src/main/java/com/sjhy/plugin/tool/ModuleUtils.java @@ -35,6 +35,13 @@ public final class ModuleUtils { * @return 路径 */ public static VirtualFile getModuleDir(@NotNull Module module) { + // 优先使用ModuleRootManager来获取module路径 + ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); + for (VirtualFile contentRoot : moduleRootManager.getContentRoots()) { + if (contentRoot.isDirectory() && contentRoot.getName().equals(module.getName())) { + return contentRoot; + } + } String modulePath = ModuleUtil.getModuleDirPath(module); // 统一路径分割符号 modulePath = modulePath.replace("\\", "/");