diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java index 97685a29eac..4361a62bcad 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; import org.eclipse.text.edits.TextEdit; public class CCodeFormatter extends CodeFormatter { @@ -147,6 +148,10 @@ public class CCodeFormatter extends CodeFormatter { } CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length); edit= codeFormatter.format(source, ast); + IStatus status= codeFormatter.getStatus(); + if (!status.isOK()) { + CCorePlugin.log(status); + } } finally { index.releaseReadLock(); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 7def3330421..c59c47c506a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -237,12 +237,16 @@ public class CodeFormatterVisitor extends CPPASTVisitor { if (DEBUG){ System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$ } - if (!fStatus.isOK()) { - CCorePlugin.log(fStatus); - } return scribe.getRootEdit(); } + /** + * @return the status collected during formatting + */ + IStatus getStatus() { + return fStatus; + } + private final TextEdit failedToFormat(RuntimeException e) { if (DEBUG) { System.out.println("COULD NOT FORMAT: " + e.getMessage()); //$NON-NLS-1$