[106158] 100% CPU for over 3 minutes opening a directory in the Navigator view with over 2000 HTML files
diff --git a/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF
index 2e3aff8..a654c62 100644
--- a/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.html.core; singleton:=true
-Bundle-Version: 0.7.0
+Bundle-Version: 0.7.1
Bundle-Activator: org.eclipse.wst.html.core.internal.HTMLCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java
index 8f2ec71..66897c2 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java
@@ -29,22 +29,38 @@
private IResourceCharsetDetector resourceCharsetDetector;
public int describe(InputStream contents, IContentDescription description) throws IOException {
- int result = IContentDescriber.VALID;
+ int result = IContentDescriber.INDETERMINATE;
- calculateSupportedOptions(contents, description);
+ if (description == null) {
+ result = computeValidity(contents);
+ }
+ else {
+ calculateSupportedOptions(contents, description);
+ // assummming we should return same 'validity' value we did
+ // when called before. (technically, could be a performance issue
+ // in future, so might want to check if any 'ol value would
+ // be ok here.
+ result = computeValidity(contents);
+ }
- // assume if we're called at all that we are valid (few types could be
- // disproved, maybe XML -- or, maybe if exception occurs above?)
return result;
}
public int describe(Reader contents, IContentDescription description) throws IOException {
- int result = IContentDescriber.VALID;
+ int result = IContentDescriber.INDETERMINATE;
- calculateSupportedOptions(contents, description);
+ if (description == null) {
+ result = computeValidity(contents);
+ }
+ else {
+ calculateSupportedOptions(contents, description);
+ // assummming we should return same 'validity' value we did
+ // when called before. (technically, could be a performance issue
+ // in future, so might want to check if hard coded 'valid' would
+ // be ok here.
+ result = computeValidity(contents);
+ }
- // assume if we're called at all that we are valid (few types could be
- // disproved, maybe XML -- or, maybe if exception occurs above?)
return result;
}
@@ -74,6 +90,18 @@
}
}
+ private int computeValidity(InputStream inputStream) {
+ // currently no contents specific check for valid HTML contents
+ // (this may change once we add XHTML content type)
+ return IContentDescriber.INDETERMINATE;
+ }
+
+ private int computeValidity(Reader reader) {
+ // currently no contents specific check for valid HTML contents
+ // (this may change once we add XHTML content type)
+ return IContentDescriber.INDETERMINATE;
+ }
+
private IResourceCharsetDetector getDetector() {
if (resourceCharsetDetector == null) {
resourceCharsetDetector = new HTMLResourceEncodingDetector();
@@ -92,7 +120,7 @@
// mulitiple times (one for each, say) that we don't waste time
// processing same
// content again.
- EncodingMemento encodingMemento = ((HTMLResourceEncodingDetector)detector).getEncodingMemento();
+ EncodingMemento encodingMemento = ((HTMLResourceEncodingDetector) detector).getEncodingMemento();
// TODO: I need to verify to see if this BOM work is always done
// by text type.
Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();