aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2014-01-28 12:49:36 (EST)
committerDawid Pakuła2014-01-28 12:49:36 (EST)
commit961c058e49707a9e47ec43112a4230c29d7ef5d8 (patch)
treef37ff22e0e6a893238893d674ead254c3a37c5e3
parent560e7a7f369bd7e12ff106edb527fe4972186987 (diff)
downloadorg.eclipse.pdt-961c058e49707a9e47ec43112a4230c29d7ef5d8.zip
org.eclipse.pdt-961c058e49707a9e47ec43112a4230c29d7ef5d8.tar.gz
org.eclipse.pdt-961c058e49707a9e47ec43112a4230c29d7ef5d8.tar.bz2
Bug 422338 - [performance] Regenerate DOM AST on each editor focusrefs/changes/12/21212/1
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=422338 Change-Id: Ib5e356c2bce1deeff8b833b988114567fc453a20 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ASTProvider.java1
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/validation/PhpReconcilingStrategy.java24
2 files changed, 17 insertions, 8 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 29a6a15..6575254 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
@@ -195,7 +195,6 @@ public final class ASTProvider {
// The instanceof check is not need but helps clients, see
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=84862
return PHPUiConstants.PHP_EDITOR_ID.equals(id)
- || PHPUiConstants.PHP_EDITOR_ID.equals(id)
|| ref.getPart(false) instanceof PHPStructuredEditor;
}
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/validation/PhpReconcilingStrategy.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/validation/PhpReconcilingStrategy.java
index c98963c..7df0c59 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/validation/PhpReconcilingStrategy.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/validation/PhpReconcilingStrategy.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Zend Technologies
@@ -30,8 +30,10 @@ import org.eclipse.php.internal.core.ast.nodes.Program;
import org.eclipse.php.internal.core.ast.util.Util;
import org.eclipse.php.internal.core.project.ProjectOptions;
import org.eclipse.php.internal.ui.PHPUiPlugin;
+import org.eclipse.php.internal.ui.editor.ASTProvider;
import org.eclipse.php.internal.ui.editor.IPhpScriptReconcilingListener;
import org.eclipse.php.internal.ui.editor.PHPStructuredEditor;
+import org.eclipse.php.ui.editor.SharedASTProvider;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -140,18 +142,25 @@ public class PhpReconcilingStrategy implements IValidator, ISourceValidator {
}
try {
- // TODO : create ast if needed
- boolean isASTNeeded = initialReconcile
- || PHPUiPlugin.getDefault().getASTProvider().isActive(unit);
- // reconcile
+ final ASTProvider astProvider = PHPUiPlugin.getDefault()
+ .getASTProvider();
+
synchronized (unit) {
unit.reconcile(true, null, fProgressMonitor);
}
- if (isASTNeeded) {
+
+ // read DOM AST from provider if avaiable
+ Program createdAST = astProvider.getAST(unit,
+ SharedASTProvider.WAIT_NO, fProgressMonitor);
+ if (astProvider.isActive(unit) && createdAST != null) {
+ return createdAST;
+ }
+
+ if (initialReconcile || astProvider.isActive(unit)) {
PHPVersion phpVersion = ProjectOptions.getPhpVersion(unit
.getScriptProject().getProject());
ASTParser newParser = ASTParser.newParser(phpVersion, unit);
- Program createdAST = newParser.createAST(null);
+ createdAST = newParser.createAST(null);
if (createdAST != null && document != null) {
createdAST.setSourceModule(unit);
createdAST.setSourceRange(0, document.getLength());
@@ -201,6 +210,7 @@ public class PhpReconcilingStrategy implements IValidator, ISourceValidator {
final IModelElement modelElement = ((PHPStructuredEditor) fEditor)
.getModelElement();
if (modelElement instanceof ISourceModule) {
+
final Program ast[] = new Program[1];
try {
SafeRunner.run(new ISafeRunnable() {