Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavid_williams2005-09-13 19:36:50 +0000
committerdavid_williams2005-09-13 19:36:50 +0000
commit288750bccc9bf1bb2171cd192fecf547bf8924bd (patch)
treecd97030c2272b552e705b06e80b891965f56321d /bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal
parent105b865db35e2cfeca8ffbd655c0c87f48a86c7f (diff)
downloadwebtools.sourceediting-288750bccc9bf1bb2171cd192fecf547bf8924bd.tar.gz
webtools.sourceediting-288750bccc9bf1bb2171cd192fecf547bf8924bd.tar.xz
webtools.sourceediting-288750bccc9bf1bb2171cd192fecf547bf8924bd.zip
[106158] 100% CPU for over 3 minutes opening a directory in the Navigator view with over 2000 HTML files
Diffstat (limited to 'bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal')
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java46
1 files changed, 37 insertions, 9 deletions
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 8f2ec71f65..66897c2c88 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 @@ public final class ContentDescriberForHTML implements ITextContentDescriber {
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 @@ public final class ContentDescriberForHTML implements ITextContentDescriber {
}
}
+ 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 @@ public final class ContentDescriberForHTML implements ITextContentDescriber {
// 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();

Back to the top