Skip to content

Commit

Permalink
Merge pull request #264 from hsz/263-NoSuchMethodError-com.intellij.u…
Browse files Browse the repository at this point in the history
…til.containers.ContainerUtil.getFirstItem

Fixed #263 - NoSuchMethodError: com.intellij.util.containers.ContainerUtil.getFirstItem
  • Loading branch information
hsz committed Oct 11, 2016
2 parents c2a9635 + fe8312f commit 961e0b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/mobi/hsz/idea/gitignore/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,16 @@ public static <T> List<T> intersection(@NotNull Collection<? extends T> collecti
public static <T> List<T> notNullize(@Nullable List<T> list) {
return list == null ? ContainerUtil.<T>newArrayList() : list;
}

/**
* Method cloned from {@link ContainerUtil#getFirstItem(List)} because of NoSuchMethodError exception
* errors related to the some API changes.
*
* @param items method to check
* @param <T> container type
* @return not null container
*/
public static <T> T getFirstItem(@Nullable List<T> items) {
return items == null || items.isEmpty() ? null : items.get(0);
}
}
2 changes: 1 addition & 1 deletion src/mobi/hsz/idea/gitignore/util/exec/ExternalExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static String bin(@NotNull IgnoreLanguage language) {
@Nullable
private static <T> T runForSingle(@NotNull IgnoreLanguage language, @NotNull String command,
@Nullable VirtualFile directory, @NotNull final ExecutionOutputParser<T> parser) {
return ContainerUtil.getFirstItem(run(language, command, directory, parser));
return Utils.getFirstItem(run(language, command, directory, parser));
}

/**
Expand Down

0 comments on commit 961e0b3

Please sign in to comment.