From e6d0eea1b9a3fe64a28437157aee680e090120e1 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 22 Feb 2016 15:41:27 -0800 Subject: [PATCH] Bug 488264 - NPE in TextEditUtil.flatten Change-Id: Ie838cc4f7f6f752673eb3254fbf7ade5c907018d --- .../org/eclipse/cdt/internal/formatter/ChangeFormatter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java index 145a7da4601..6fc4cfc5d24 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java @@ -90,7 +90,7 @@ public class ChangeFormatter { // Calculate formatting changes for the regions after the refactoring changes. ICProject project = tu.getCProject(); - Map options = new HashMap(project.getOptions(true)); + Map options = new HashMap<>(project.getOptions(true)); options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu); // Allow all comments to be indented. options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, @@ -102,7 +102,8 @@ public class ChangeFormatter { TextEdit combinedFormatEdit = new MultiTextEdit(); for (TextEdit formatEdit : formatEdits) { - combinedFormatEdit = TextEditUtil.merge(combinedFormatEdit, formatEdit); + if (formatEdit != null) + combinedFormatEdit = TextEditUtil.merge(combinedFormatEdit, formatEdit); } formatEdits = TextEditUtil.flatten(combinedFormatEdit).removeChildren();