Author: vrubezhny
Date: 2012-08-10 17:35:24 -0400 (Fri, 10 Aug 2012)
New Revision: 42981
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java
Log:
JBIDE-12405
As-you-type validation works slow when many strings are being added
Partition to process are stored in a list insteado of a set due to allow ordering.
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java 2012-08-10
19:29:39 UTC (rev 42980)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java 2012-08-10
21:35:24 UTC (rev 42981)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.validation.java;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -73,7 +74,7 @@
private boolean fIsCanceled = false;
private boolean fInRewriteSession = false;
private IDocumentRewriteSessionListener fDocumentRewriteSessionListener = new
DocumentRewriteSessionListener();
- private Set<ITypedRegion> fPartitionsToProcess = new
HashSet<ITypedRegion>();
+ private List<ITypedRegion> fPartitionsToProcess = new
ArrayList<ITypedRegion>();
private int fStartPartitionsToProcess = -1;
private int fEndPartitionsToProcess = -1;
private int fStartRegionToProcess = -1;
@@ -231,7 +232,6 @@
}
if (message instanceof ValidationMessage && getAnnotationModel() != null) {
ValidationMessage valMessage = (ValidationMessage)message;
-
IEditorInput editorInput= fEditor.getEditorInput();
if (editorInput != null) {
boolean cleanAllAnnotations =
Boolean.TRUE.equals(message.getAttribute(TempMarkerManager.CLEAN_ALL_ANNOTATIONS_ATTRIBUTE));
@@ -361,6 +361,7 @@
protected void process(DirtyRegion dirtyRegion) {
IDocument doc = getDocument();
+
if (!isEditorDirty() || !isInstalled() || isInRewrite() || dirtyRegion == null || doc
== null || fIsCanceled) {
return;
}
@@ -420,17 +421,13 @@
protected void endProcessing() {
if (fValidatorManager == null || fReporter == null || fStartPartitionsToProcess == -1
|| fEndPartitionsToProcess == -1)
return;
-// long t = System.currentTimeMillis();
-// String message = "";
fReporter.clearAnnotations(fStartPartitionsToProcess, fEndPartitionsToProcess);
if (fPartitionsToProcess != null && !fPartitionsToProcess.isEmpty()) {
fValidatorManager.validateString(
Arrays.asList(fPartitionsToProcess.toArray(new
IRegion[fPartitionsToProcess.size()])),
fHelper, fReporter);
-// message += "; validateString: " + fPartitionsToProcess.size() + "
regions; ";
}
-// else { message += "; validateString: 0 regions; "; }
if (isJavaElementValidationRequired()) {
fReporter.clearAlwaysRemoveAnnotations();
@@ -440,12 +437,10 @@
new Region(fStartRegionToProcess, fEndRegionToProcess - fStartRegionToProcess)
}),
fHelper, fReporter);
-// message += "; validateJavaElement: one region";
}
-// else { message += "; validateJavaElement: 0 regions"; }
-// System.out.println("[" + (System.currentTimeMillis() - t) + "ms]:
" + message);
}
+
private boolean isJavaElementValidationRequired() {
ICompilationUnit unit = fReporter.getCompilationUnit();
if (unit == null)
Show replies by date