mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 22:25:25 +02:00
Bug 371165 - Invalid formatting of newly created classes.
This commit is contained in:
parent
8ae8121492
commit
d39f64adfb
1 changed files with 4 additions and 0 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.FileContent;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
|
||||
|
@ -258,6 +259,9 @@ public class CCodeFormatter extends CodeFormatter {
|
|||
}
|
||||
if (tu != null && source != null) {
|
||||
try {
|
||||
// Create a private working copy and set it contents to source.
|
||||
if (tu.isWorkingCopy())
|
||||
tu = ((IWorkingCopy) tu).getOriginalElement();
|
||||
tu = tu.getWorkingCopy();
|
||||
tu.getBuffer().setContents(source);
|
||||
} catch (CModelException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue