Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2017-06-16 14:51:41 -0400
committerKaloyan Raev2017-06-19 04:36:45 -0400
commit4674007bfc7de9e8e4c367cdeeb5d4e97201e569 (patch)
tree072bc67a2ba58dec29fcfe9ab1665e5133e64af3
parent3e71194039375c733a625ca1737318681c2b894f (diff)
downloadorg.eclipse.pdt-4674007bfc7de9e8e4c367cdeeb5d4e97201e569.tar.gz
org.eclipse.pdt-4674007bfc7de9e8e4c367cdeeb5d4e97201e569.tar.xz
org.eclipse.pdt-4674007bfc7de9e8e4c367cdeeb5d4e97201e569.zip
Bug 518410 - revert patches for bug 515526 and bug 518128
Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java39
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java70
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredTextViewer.java69
3 files changed, 89 insertions, 89 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java
index 77c0b4323..0678e1dc0 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java
@@ -212,13 +212,13 @@ public final class ASTProvider {
private static final String DEBUG_PREFIX = "ASTProvider > "; //$NON-NLS-1$
- private volatile ISourceModule fReconcilingJavaElement;
+ private ISourceModule fReconcilingJavaElement;
private ISourceModule fActiveJavaElement;
private Program fAST;
private ActivationListener fActivationListener;
private Object fReconcileLock = new Object();
private Object fWaitLock = new Object();
- private volatile boolean fIsReconciling;
+ private boolean fIsReconciling;
private IWorkbenchPart fActiveEditor;
/**
@@ -301,7 +301,7 @@ public final class ASTProvider {
* @return <code>true</code> if the given compilation unit is the active one
* @since 3.1
*/
- public synchronized boolean isActive(ISourceModule cu) {
+ public boolean isActive(ISourceModule cu) {
return cu != null && cu.equals(fActiveJavaElement);
}
@@ -324,8 +324,8 @@ public final class ASTProvider {
synchronized (fReconcileLock) {
fIsReconciling = true;
fReconcilingJavaElement = javaElement;
+ cache(null, javaElement);
}
- cache(null, javaElement);
}
/**
@@ -469,34 +469,29 @@ public final class ASTProvider {
final boolean canReturnNull = waitFlag == SharedASTProvider.WAIT_NO
|| (waitFlag == SharedASTProvider.WAIT_ACTIVE_ONLY && !(isActiveElement && fAST == null));
boolean isReconciling = false;
- final ISourceModule activeElement;
if (isActiveElement) {
synchronized (fReconcileLock) {
- activeElement = fReconcilingJavaElement;
isReconciling = isReconciling(input);
if (!isReconciling && !canReturnNull) {
aboutToBeReconciled(input);
}
}
- } else {
- activeElement = null;
}
if (isReconciling) {
try {
+ final ISourceModule activeElement = fReconcilingJavaElement;
+
// Wait for AST
synchronized (fWaitLock) {
- if (isReconciling(input)) {
- if (DEBUG) {
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "waiting for AST for: " //$NON-NLS-1$ //$NON-NLS-2$
- + input.getElementName());
- }
- fWaitLock.wait(30000); // XXX: The 30 seconds timeout is
- // an
- // attempt to at least avoid a
- // deadlock. See
- // https://bugs.eclipse.org/366048#c21
+ if (DEBUG) {
+ System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "waiting for AST for: " //$NON-NLS-1$ //$NON-NLS-2$
+ + input.getElementName());
}
+ fWaitLock.wait(30000); // XXX: The 30 seconds timeout is an
+ // attempt to at least avoid a
+ // deadlock. See
+ // https://bugs.eclipse.org/366048#c21
}
// Check whether active element is still valid
@@ -554,8 +549,10 @@ public final class ASTProvider {
* @return <code>true</code> if reported as currently being reconciled
*/
private boolean isReconciling(ISourceModule javaElement) {
- return javaElement != null && javaElement.equals(fReconcilingJavaElement) && fIsReconciling
- && !(javaElement instanceof IExternalSourceModule) && !isValidatorDisabled(javaElement);
+ synchronized (fReconcileLock) {
+ return javaElement != null && javaElement.equals(fReconcilingJavaElement) && fIsReconciling
+ && !(javaElement instanceof IExternalSourceModule) && !isValidatorDisabled(javaElement);
+ }
}
private boolean isValidatorDisabled(ISourceModule javaElement) {
@@ -698,7 +695,6 @@ public final class ASTProvider {
}
synchronized (fReconcileLock) {
- fIsReconciling = false;
if (javaElement == null || !javaElement.equals(fReconcilingJavaElement)) {
if (DEBUG) {
@@ -711,6 +707,7 @@ public final class ASTProvider {
return;
}
+ fIsReconciling = progressMonitor != null && progressMonitor.isCanceled();
cache(ast, javaElement);
}
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
index b0ee4f311..f8bdba2d1 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
@@ -49,6 +49,7 @@ import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.link.*;
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
+import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.source.*;
import org.eclipse.jface.text.source.ImageUtilities;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
@@ -130,8 +131,10 @@ import org.eclipse.wst.sse.ui.internal.actions.ActionDefinitionIds;
import org.eclipse.wst.sse.ui.internal.contentassist.StructuredContentAssistant;
import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
import org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingStrategy;
+import org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor;
import org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey;
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
+import org.eclipse.wst.sse.ui.reconcile.ISourceReconcilingListener;
import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
import com.ibm.icu.text.BreakIterator;
@@ -290,6 +293,11 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
private boolean fMarkImplementors;
/**
+ * Fix for outline synchronization while reconcile
+ */
+ protected volatile boolean fReconcileSelection = false;
+
+ /**
* The override and implements indicator manager for this editor.
*
* @since 3.0
@@ -1433,6 +1441,8 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
/** The information presenter. */
protected InformationPresenter fInformationPresenter;
+ private ISourceReconcilingListener fEditorReconcilingListener = new EditorReconcilingListener();
+
public PHPStructuredEditor() {
/**
* Bug fix: #158170 Set WST's folding support enablement according to
@@ -2549,6 +2559,8 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
fInformationPresenter.setSizeConstraints(60, 10, true, true);
fInformationPresenter.install(getSourceViewer());
+ addEditorReconcilingListener(getSourceViewerConfiguration(), getTextViewer());
+
fEditorSelectionChangedListener = new EditorSelectionChangedListener();
fEditorSelectionChangedListener.install(getSelectionProvider());
PlatformUI.getWorkbench().addWindowListener(fActivationListener);
@@ -2556,6 +2568,49 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
setHelpContextId(IPHPHelpContextIds.EDITOR_PREFERENCES);// $NON-NLS-1$
}
+ private void addEditorReconcilingListener(SourceViewerConfiguration config, StructuredTextViewer textViewer) {
+ IReconciler reconciler = config.getReconciler(textViewer);
+ if (reconciler instanceof DocumentRegionProcessor) {
+ ((DocumentRegionProcessor) reconciler).addReconcilingListener(fEditorReconcilingListener);
+ }
+ }
+
+ private class EditorReconcilingListener implements ISourceReconcilingListener {
+
+ @Override
+ public void aboutToBeReconciled() {
+ PHPStructuredEditor.this.aboutToBeReconciled();
+
+ }
+
+ @Override
+ public void reconciled(IDocument document, IAnnotationModel model, boolean forced,
+ IProgressMonitor progressMonitor) {
+ }
+
+ }
+
+ @Override
+ protected void setSourceViewerConfiguration(SourceViewerConfiguration config) {
+ SourceViewerConfiguration old = config;
+ super.setSourceViewerConfiguration(config);
+ StructuredTextViewer stv = getTextViewer();
+ if (stv != null) {
+ removeEditorReconcilingListener(old, stv);
+ addEditorReconcilingListener(config, stv);
+ }
+
+ }
+
+ private void removeEditorReconcilingListener(SourceViewerConfiguration config, StructuredTextViewer textViewer) {
+
+ IReconciler reconciler = config.getReconciler(textViewer);
+ if (reconciler instanceof DocumentRegionProcessor) {
+ ((DocumentRegionProcessor) reconciler).removeReconcilingListener(fEditorReconcilingListener);
+ }
+
+ }
+
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
IFile resource = null;
@@ -3137,6 +3192,7 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
@Override
public void aboutToBeReconciled() {
+ fReconcileSelection = true;
// Notify AST provider
PHPUiPlugin.getDefault().getASTProvider().aboutToBeReconciled((ISourceModule) getModelElement());
// Notify listeners
@@ -3164,6 +3220,7 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
ISourceModule inputModelElement = (ISourceModule) getModelElement();
phpPlugin.getASTProvider().reconciled(ast, inputModelElement, progressMonitor);
+ this.fReconcileSelection = false;
// Notify listeners
Object[] listeners = fReconcilingListeners.getListeners();
@@ -3211,6 +3268,7 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
if (unit != null) {
try {
if (reconcile) {
+ fReconcileSelection = false;
ScriptModelUtil.reconcile(unit);
return unit.getElementAt(offset);
} else if (unit.isConsistent())
@@ -3266,6 +3324,10 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
/**
* Updates the occurrences annotations based on the current selection.
*
+ * TODO : since {@link PHPStructuredEditor#aboutToBeChangedEvent} currently
+ * doesn't work, we check if " document.getLength() != astRoot.getEnd() " to
+ * identify if the document was not already reconciled
+ *
* @param selection
* the text selection
* @param astRoot
@@ -3292,7 +3354,7 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
protected IStatus run(IProgressMonitor monitor) {
Program astRoot = null;
try {
- astRoot = SharedASTProvider.getAST((ISourceModule) sourceModule, SharedASTProvider.WAIT_NO,
+ astRoot = SharedASTProvider.getAST((ISourceModule) sourceModule, SharedASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor());
} catch (ModelException e) {
Logger.logException(e);
@@ -3328,6 +3390,12 @@ public class PHPStructuredEditor extends StructuredTextEditor implements IPHPScr
if (document == null)
return;
+ // TODO: see the method comment, need to be removed once
+ // PHPStructuredEditor#aboutToBeChangedEvent is used
+ if (document.getLength() != astRoot.getEnd() || this.fReconcileSelection) {
+ return;
+ }
+
boolean hasChanged = false;
if (document instanceof IDocumentExtension4) {
int offset = selection.getOffset();
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredTextViewer.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredTextViewer.java
index e22b1a5ef..830fdd936 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredTextViewer.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredTextViewer.java
@@ -75,59 +75,6 @@ import org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor;
public class PHPStructuredTextViewer extends StructuredTextViewer {
- private class EditorReconcilingListener implements IDocumentListener, ITextInputListener {
-
- public void install() {
- StyledText text = getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- addTextInputListener(this);
-
- IDocument document = getDocument();
- if (document != null) {
- document.addDocumentListener(this);
- }
- }
-
- public void uninstall() {
- removeTextInputListener(this);
- IDocument document = getDocument();
- if (document != null) {
- document.removeDocumentListener(this);
- }
- }
-
- @Override
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput != null) {
- oldInput.removeDocumentListener(this);
- }
- }
-
- @Override
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null) {
- newInput.addDocumentListener(this);
- if (getTextEditor() instanceof PHPStructuredEditor) {
- ((PHPStructuredEditor) getTextEditor()).aboutToBeReconciled();
- }
- }
- }
-
- @Override
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- @Override
- public void documentChanged(DocumentEvent event) {
- if (getTextEditor() instanceof PHPStructuredEditor) {
- ((PHPStructuredEditor) getTextEditor()).aboutToBeReconciled();
- }
- }
-
- }
-
/**
* Text operation code for requesting the outline for the current input.
*/
@@ -152,7 +99,6 @@ public class PHPStructuredTextViewer extends StructuredTextViewer {
private IInformationPresenter fHierarchyPresenter;
private IAnnotationHover fProjectionAnnotationHover;
private boolean fFireSelectionChanged = true;
- private EditorReconcilingListener fEditorReconcilingListener;
private IDocumentAdapter documentAdapter;
@@ -494,14 +440,6 @@ public class PHPStructuredTextViewer extends StructuredTextViewer {
@Override
public void configure(SourceViewerConfiguration configuration) {
- // need to install the EditorReconcilingListener before reconciler is
- // installed so that PHPStructuredEditor.aboutToBeReconciled() can be
- // called when editor opened
- if (fEditorReconcilingListener == null) {
- fEditorReconcilingListener = new EditorReconcilingListener();
- fEditorReconcilingListener.install();
- }
-
super.configure(configuration);
// release old annotation hover before setting new one
@@ -566,10 +504,6 @@ public class PHPStructuredTextViewer extends StructuredTextViewer {
fOutlinePresenter.uninstall();
fOutlinePresenter = null;
}
- if (fEditorReconcilingListener != null) {
- fEditorReconcilingListener.uninstall();
- fEditorReconcilingListener = null;
- }
super.unconfigure();
}
@@ -757,7 +691,8 @@ public class PHPStructuredTextViewer extends StructuredTextViewer {
// IPhpScriptReconcilingListener attached to PHPStructuredEditor and
// defined in the PHPStructuredTextViewer constructor).
synchronized (this) {
- if (fTextEditor instanceof PHPStructuredEditor) {
+ if (fTextEditor instanceof PHPStructuredEditor
+ && !((PHPStructuredEditor) fTextEditor).fReconcileSelection) {
super.firePostSelectionChanged(offset, length);
fPostSelectionOffset = -1;
fPostSelectionLength = -1;

Back to the top