Skip to content

Commit a82a489

Browse files
Flanker-MSFTFlanker-MSFT
authored andcommitted
Swallow exception when validate create function action is available
1 parent 55493fa commit a82a489

File tree

1 file changed

+11
-7
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/action

1 file changed

+11
-7
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/action/CreateFunctionAction.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,19 @@ protected boolean isAvailable(final DataContext dataContext) {
132132
if (project == null || project.isDisposed()) {
133133
return false;
134134
}
135-
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
136-
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
137-
if (view != null) {
138-
final List<PsiDirectory> dirs = Arrays.stream(view.getDirectories()).filter(Objects::nonNull).toList();
139-
for (final PsiDirectory dir : dirs) {
140-
if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && doCheckPackageExists(dir)) {
141-
return true;
135+
try {
136+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
137+
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
138+
if (view != null) {
139+
final List<PsiDirectory> dirs = Arrays.stream(view.getDirectories()).filter(Objects::nonNull).toList();
140+
for (final PsiDirectory dir : dirs) {
141+
if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && doCheckPackageExists(dir)) {
142+
return true;
143+
}
142144
}
143145
}
146+
} catch (final RuntimeException e) {
147+
// swallow exception when check action availability
144148
}
145149
return false;
146150
}

0 commit comments

Comments
 (0)