From 5401a8563fafeee389aee23d698801e7df1bef44 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Wed, 23 Sep 2020 10:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D.idea?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/service/impl/TableInfoServiceImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java index fbb037e..42a0e6b 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java @@ -390,6 +390,19 @@ public class TableInfoServiceImpl implements TableInfoService { } // 获取.idea路径 VirtualFile ideaDir = baseDir.findChild(".idea"); + // 当获取失败时尝试通过父级目录获取,最多向上找3级目录 + VirtualFile tmpDir = baseDir; + for (int i = 0; i < 3; i++) { + if (ideaDir != null) { + break; + } + tmpDir = tmpDir.getParent(); + // 当没有父级目录时不再继续 + if (tmpDir == null) { + break; + } + ideaDir = tmpDir.findChild(".idea"); + } if (ideaDir == null) { Messages.showInfoMessage(".idea路径获取失败", MsgValue.TITLE_INFO); String errorMsg = String.format("baseDir:%s, not found .idea child directory", baseDir.getPath());