diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java index 5724c8de734..fd0de4832fa 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java @@ -208,7 +208,12 @@ public class ASTCache { try { IASTTranslationUnit ast= getAST(tUnit, index, wait, monitor); ILanguage lang= (tUnit instanceof TranslationUnit) ? ((TranslationUnit) tUnit).getLanguageOfContext() : tUnit.getLanguage(); - return astRunnable.runOnAST(lang, ast); + if (ast == null) { + return astRunnable.runOnAST(lang, ast); + } + synchronized (ast) { + return astRunnable.runOnAST(lang, ast); + } } catch (CoreException e) { return e.getStatus(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java index 3962cb6ac5a..521dc79657f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java @@ -126,9 +126,9 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS forced= workingCopy.isConsistent(); ast= workingCopy.reconcile(computeAST, true, fProgressMonitor); } - } catch(OperationCanceledException oce) { + } catch (OperationCanceledException oce) { // document was modified while parsing - } catch(CModelException e) { + } catch (CModelException e) { IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$ CUIPlugin.getDefault().log(status); } finally { @@ -138,7 +138,16 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS index= ast.getIndex(); } try { - ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor); + if (ast == null) { + ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor); + } else { + synchronized (ast) { + ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor); + } + } + } catch(Exception e) { + IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$ + CUIPlugin.getDefault().log(status); } finally { if (index != null) { index.releaseReadLock();