X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaReconcilingStrategy.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaReconcilingStrategy.java index d12ddf9..8294154 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaReconcilingStrategy.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaReconcilingStrategy.java @@ -1,13 +1,10 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at +/*********************************************************************************************************************************** + * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ + * Contributors: IBM Corporation - initial API and implementation + **********************************************************************************************************************************/ package net.sourceforge.phpdt.internal.ui.text.java; @@ -17,6 +14,7 @@ import net.sourceforge.phpdt.ui.IWorkingCopyManager; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.reconciler.DirtyRegion; @@ -31,14 +29,24 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili private ITextEditor fEditor; private IWorkingCopyManager fManager; + private IDocumentProvider fDocumentProvider; + private IProgressMonitor fProgressMonitor; + private boolean fNotify = true; + private IJavaReconcilingListener fJavaReconcilingListener; + + private boolean fIsJavaReconcilingListener; + public JavaReconcilingStrategy(ITextEditor editor) { fEditor = editor; fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); fDocumentProvider = PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider(); + fIsJavaReconcilingListener = fEditor instanceof IJavaReconcilingListener; + if (fIsJavaReconcilingListener) + fJavaReconcilingListener = (IJavaReconcilingListener) fEditor; } private IProblemRequestorExtension getProblemRequestorExtension() { @@ -49,7 +57,7 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili } private void reconcile() { - // // try { + // // try { // // /* fix for missing cancel flag communication */ // IProblemRequestorExtension extension = getProblemRequestorExtension(); @@ -57,9 +65,9 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili // extension.setProgressMonitor(fProgressMonitor); // // // reconcile - //// synchronized (unit) { - //// unit.reconcile(true, fProgressMonitor); - //// } + //// synchronized (unit) { + //// unit.reconcile(true, fProgressMonitor); + //// } // // Parser parser = new Parser(); // parser.initializeScanner(); @@ -67,7 +75,7 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili // String text = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput()).get(); // parser.init(text); // parser.reportSyntaxError(); - //// checkAndReportBracketAnomalies(parser.problemReporter()); + //// checkAndReportBracketAnomalies(parser.problemReporter()); // // /* fix for missing cancel flag communication */ // if (extension != null) @@ -84,37 +92,52 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili // } // JDT implementation: - ICompilationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput()); - if (unit != null) { - try { - - /* fix for missing cancel flag communication */ - IProblemRequestorExtension extension = getProblemRequestorExtension(); - if (extension != null) - extension.setProgressMonitor(fProgressMonitor); + try { + ICompilationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput()); + if (unit != null) { + try { - // reconcile - synchronized (unit) { - unit.reconcile(true, fProgressMonitor); - } + /* fix for missing cancel flag communication */ + IProblemRequestorExtension extension = getProblemRequestorExtension(); + if (extension != null) + extension.setProgressMonitor(fProgressMonitor); - /* fix for missing cancel flag communication */ - if (extension != null) - extension.setProgressMonitor(null); + // reconcile + synchronized (unit) { + unit.reconcile(true, fProgressMonitor); + } - // update participants - try { - if (fEditor instanceof IReconcilingParticipant && fNotify && !fProgressMonitor.isCanceled()) { - IReconcilingParticipant p = (IReconcilingParticipant) fEditor; - p.reconciled(); + /* fix for missing cancel flag communication */ + if (extension != null) + extension.setProgressMonitor(null); + + // update participants + try { + if (fEditor instanceof IReconcilingParticipant && fNotify && !fProgressMonitor.isCanceled()) { + IReconcilingParticipant p = (IReconcilingParticipant) fEditor; + p.reconciled(); + } + } finally { + fNotify = true; } - } finally { - fNotify = true; - } - } catch (JavaModelException x) { - // swallow exception + } catch (JavaModelException x) { + // swallow exception + } + } + } finally { + // Always notify listeners, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=55969 for the final solution + try { + if (fIsJavaReconcilingListener) { + IProgressMonitor pm = fProgressMonitor; + if (pm == null) + pm = new NullProgressMonitor(); + fJavaReconcilingListener.reconciled(null, !fNotify, pm); + } + } finally { + fNotify = true; } + } } @@ -155,9 +178,30 @@ public class JavaReconcilingStrategy implements IReconcilingStrategy, IReconcili /** * Tells this strategy whether to inform its participants. * - * @param notify true if participant should be notified + * @param notify + * true if participant should be notified */ public void notifyParticipants(boolean notify) { fNotify = notify; } -} + + /** + * Tells this strategy whether to inform its listeners. + * + * @param notify + * true if listeners should be notified + */ + public void notifyListeners(boolean notify) { + fNotify = notify; + } + + /** + * Called before reconciling is started. + * + * @since 3.0 + */ + public void aboutToBeReconciled() { + if (fIsJavaReconcilingListener) + fJavaReconcilingListener.aboutToBeReconciled(); + } +} \ No newline at end of file