Skip to content

Commit 5011e29

Browse files
committed
fix possible npe in project settings on non open project editor Haehnchen#288
1 parent b5cb90e commit 5011e29

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/fr/adrienbrault/idea/symfony2plugin/TwigHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ private static void addFileInsideTwigPath(Project project, String templatePath,
240240
}
241241
}
242242

243-
public static List<TwigPath> getTwigNamespaces(Project project) {
243+
public static List<TwigPath> getTwigNamespaces(@NotNull Project project) {
244244
return getTwigNamespaces(project, true);
245245
}
246246

247-
public static List<TwigPath> getTwigNamespaces(Project project, boolean includeSettings) {
247+
public static List<TwigPath> getTwigNamespaces(@NotNull Project project, boolean includeSettings) {
248248
List<TwigPath> twigPaths = new ArrayList<TwigPath>();
249249
PhpIndex phpIndex = PhpIndex.getInstance(project);
250250

src/fr/adrienbrault/idea/symfony2plugin/ui/TwigSettingsForm.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void mouseClicked(MouseEvent e) {
7070
super.mouseClicked(e);
7171
TwigSettingsForm.this.resetList();
7272

73-
ArrayList<TwigPath> sortableLookupItems = new ArrayList<TwigPath>();
73+
List<TwigPath> sortableLookupItems = new ArrayList<TwigPath>();
7474
sortableLookupItems.addAll(TwigHelper.getTwigNamespaces(TwigSettingsForm.this.project, false));
7575
Collections.sort(sortableLookupItems);
7676

@@ -84,7 +84,13 @@ public void mouseClicked(MouseEvent e) {
8484
}
8585

8686
private void attachItems(boolean includeSettings) {
87-
ArrayList<TwigPath> sortableLookupItems = new ArrayList<TwigPath>();
87+
88+
// dont load on project less context
89+
if(this.project == null) {
90+
return;
91+
}
92+
93+
List<TwigPath> sortableLookupItems = new ArrayList<TwigPath>();
8894
sortableLookupItems.addAll(TwigHelper.getTwigNamespaces(this.project, includeSettings));
8995
Collections.sort(sortableLookupItems);
9096

0 commit comments

Comments
 (0)