Merge pull request #1661 from eclipse/cd_fixNPE

fixed npe in formatter in tests
This commit is contained in:
Christian Dietrich 2021-01-11 11:27:01 +01:00 committed by GitHub
commit e3d79e99f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,7 @@ public class FileAwareTestLanguageFormatter extends AbstractJavaFormatter {
protected void format(PackageDeclaration pkg, IFormattableDocument doc) {
doc.append(regionFor(pkg).feature(FileAwarePackage.Literals.PACKAGE_DECLARATION__NAME), it -> it.setNewLines(2));
Import last = Iterables.getLast(pkg.getImports());
Import last = Iterables.getLast(pkg.getImports(), null);
for (Import imp : pkg.getImports()) {
doc.format(imp);
doc.append(imp, it -> it.setNewLines(imp == last ? 2 : 1));