simple cleanup of unit tests and logged exceptions
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/modelhandler/JSPModelLoader.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/modelhandler/JSPModelLoader.java
index 48ed728..bd3c98e 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/modelhandler/JSPModelLoader.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/modelhandler/JSPModelLoader.java
@@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jst.jsp.core.PageDirectiveAdapter;
import org.eclipse.jst.jsp.core.document.PageDirectiveAdapterFactory;
import org.eclipse.jst.jsp.core.document.PageDirectiveWatcherFactory;
@@ -123,12 +124,12 @@
* ever the loader is prepared to do). If the resource can not be found
* (and therefore a model can not be created), then it should return null.
*/
- // public void load(Reader reader, IStructuredModel model, EncodingRule
+ // public void load(Reader reader, IStructuredModel model, EncodingRule
// encodingRule) throws java.io.IOException {
- // initializeEmbeddedTypeFromStream(reader, model);
- // setLanguageInPageDirective(model);
- // super.load(reader, model, encodingRule);
- // }
+ // initializeEmbeddedTypeFromStream(reader, model);
+ // setLanguageInPageDirective(model);
+ // super.load(reader, model, encodingRule);
+ // }
/**
* This method must return a new instance of IStructuredDocument, that has
* been initialized with appropriate parser. For many loaders, the
@@ -144,7 +145,7 @@
public IStructuredDocument newStructuredDocument() {
IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser());
((BasicStructuredDocument) structuredDocument).setReParser(new JSPReParser());
- // structuredDocument.setDocumentPartitioner(new
+ // structuredDocument.setDocumentPartitioner(new
// JSPJavaDocumentPartioner());
// even though this is an "empty model" ... we want it to have at
// least the
@@ -221,27 +222,27 @@
* This init method is for the case where we are getting the embedded type
* from the input stream specifically.
*/
- // private void initializeEmbeddedTypeFromStream(Reader reader,
+ // private void initializeEmbeddedTypeFromStream(Reader reader,
// IStructuredModel model) throws IOException {
- // IFile file = ResourceUtil.getFileFor(model);
- // JSPDocumentLoader jspDocumentLoader =(JSPDocumentLoader)
+ // IFile file = ResourceUtil.getFileFor(model);
+ // JSPDocumentLoader jspDocumentLoader =(JSPDocumentLoader)
// getDocumentLoader();
- // EmbeddedTypeHandler inputEmbeddedContentType =
+ // EmbeddedTypeHandler inputEmbeddedContentType =
// jspDocumentLoader.getEmbeddedType(file);
- // EmbeddedTypeHandler existingEmbeddedType = getEmbeddedType(model);
- // // we don't expect the existing type to be null, but if it is, then
- // // this is a simply init case, not re-init
- // if (existingEmbeddedType == null) {
- // initializeEmbeddedType(model, inputEmbeddedContentType);
- // }
- // else {
- // if (existingEmbeddedType != inputEmbeddedContentType) {
- // // only need to reinitialize if truely different
- // reInitializeEmbeddedType(model, existingEmbeddedType,
+ // EmbeddedTypeHandler existingEmbeddedType = getEmbeddedType(model);
+ // // we don't expect the existing type to be null, but if it is, then
+ // // this is a simply init case, not re-init
+ // if (existingEmbeddedType == null) {
+ // initializeEmbeddedType(model, inputEmbeddedContentType);
+ // }
+ // else {
+ // if (existingEmbeddedType != inputEmbeddedContentType) {
+ // // only need to reinitialize if truely different
+ // reInitializeEmbeddedType(model, existingEmbeddedType,
// inputEmbeddedContentType);
- // }
- // }
- // }
+ // }
+ // }
+ // }
/**
* This init method is for the case where we are creating an empty model,
* which we always do.
@@ -279,8 +280,8 @@
// being initialized, and doesn't even have content
// or an ID yet. I thought I'd leave, since it wouldn't
// hurt, in case its called in other circumstances.
- // String language = getLanguage(model);
- // pageDirectiveAdapter.setLanguage(language);
+ // String language = getLanguage(model);
+ // pageDirectiveAdapter.setLanguage(language);
}
/**
@@ -323,9 +324,8 @@
localHeadParser.set(structuredDocument);
try {
result = localHeadParser.getLanguage();
- }
- catch (IOException e) {
- //impossible
+ } catch (IOException e) {
+ // impossible
// TODO need to reconsider design to avoid
throw new Error(e);
}
@@ -363,41 +363,45 @@
// to accomplish this, we'll just remove all, then
// add back with a call to pre-load adapt.
// let clients decide to unload adapters from document
- // Collection oldAdapters = document.getAdapters();
- // Iterator oldAdaptersIterator = oldAdapters.iterator();
- // while (oldAdaptersIterator.hasNext()) {
- // INodeAdapter oldAdapter = (INodeAdapter)
+ // Collection oldAdapters = document.getAdapters();
+ // Iterator oldAdaptersIterator = oldAdapters.iterator();
+ // while (oldAdaptersIterator.hasNext()) {
+ // INodeAdapter oldAdapter = (INodeAdapter)
// oldAdaptersIterator.next();
- // if (oldAdapter != pageDirectiveAdapter && oldAdapter !=
+ // if (oldAdapter != pageDirectiveAdapter && oldAdapter !=
// propagatingAdapter && oldAdapter != modelQueryAdapter) {
- // // DO NOT remove directly!
- // // can change contents while in notifity loop!
- // //oldAdaptersIterator.remove();
- // document.removeAdapter(oldAdapter);
- // }
- // }
+ // // DO NOT remove directly!
+ // // can change contents while in notifity loop!
+ // //oldAdaptersIterator.remove();
+ // document.removeAdapter(oldAdapter);
+ // }
+ // }
// DMW: I believe something like the following is needed,
// since releases cached adapters
- // if (document instanceof DocumentImpl) {
- // ((DocumentImpl) document).releaseDocumentType();
- // ((DocumentImpl) document).releaseStyleSheets();
- // }
+ // if (document instanceof DocumentImpl) {
+ // ((DocumentImpl) document).releaseDocumentType();
+ // ((DocumentImpl) document).releaseStyleSheets();
+ // }
// remember, embedded type factories are automatically cleared when
// embededType changed
pageDirectiveAdapter.setEmbeddedType(newEmbeddedContentType);
- // // but still need to clear the page directive watchers, and let
+ // // but still need to clear the page directive watchers, and let
// them be rediscovered (with new, accurate node as target)
- // pageDirectiveAdapter.clearPageWatchers();
+ // pageDirectiveAdapter.clearPageWatchers();
if (newEmbeddedContentType != null) {
newEmbeddedContentType.initializeFactoryRegistry(model.getFactoryRegistry());
newEmbeddedContentType.initializeParser((JSPCapableParser) structuredDocument.getParser());
// partitioner setup is the responsibility of this loader
- if (newEmbeddedContentType.getFamilyId().equals(IContentTypeIdentifier.ContentTypeID_SSEXML)) {
- ((StructuredTextPartitionerForJSP) structuredDocument.getDocumentPartitioner()).setEmbeddedPartitioner(new StructuredTextPartitionerForXML());
- }
- else if (newEmbeddedContentType.getFamilyId().equals(IContentTypeIdentifier.ContentTypeID_HTML)) {
- ((StructuredTextPartitionerForJSP) structuredDocument.getDocumentPartitioner()).setEmbeddedPartitioner(new StructuredTextPartitionerForHTML());
+ IDocumentPartitioner documentPartitioner = structuredDocument.getDocumentPartitioner();
+ // ISSUE: this logic is flawed, not sure of original intent, but
+ // added null/type checks for safety.
+ if (documentPartitioner != null && documentPartitioner instanceof StructuredTextPartitionerForJSP) {
+ if (newEmbeddedContentType.getFamilyId().equals(IContentTypeIdentifier.ContentTypeID_SSEXML)) {
+ ((StructuredTextPartitionerForJSP) documentPartitioner).setEmbeddedPartitioner(new StructuredTextPartitionerForXML());
+ } else if (newEmbeddedContentType.getFamilyId().equals(IContentTypeIdentifier.ContentTypeID_HTML)) {
+ ((StructuredTextPartitionerForJSP) documentPartitioner).setEmbeddedPartitioner(new StructuredTextPartitionerForHTML());
+ }
}
}
// adding language here, in this convienent central
@@ -479,9 +483,8 @@
EmbeddedTypeHandler newEmbeddedContentType = existingEmbeddedType.newInstance();
if (existingEmbeddedType == null) {
initEmbeddedType(newModel);
- }
- else {
- //initEmbeddedType(newModel);
+ } else {
+ // initEmbeddedType(newModel);
initCloneOfEmbeddedType(newModel, existingEmbeddedType, newEmbeddedContentType);
}
setLanguageInPageDirective(newModel);
@@ -508,8 +511,7 @@
// (documents) adapters,
// so need need to use the old one to undo the old state data
reInitializeEmbeddedType(model, oldHandler, newHandler);
- }
- else {
+ } else {
// for language ... we someday MIGHT have to do something
// here, but for now, we don't have any model-side language
// sensitive adapters.
@@ -550,8 +552,7 @@
byte[] smallerBuffer = new byte[nRead];
System.arraycopy(smallBuffer, 0, smallerBuffer, 0, nRead);
returnBuffer = smallerBuffer;
- }
- else {
+ } else {
returnBuffer = smallBuffer;
}
return returnBuffer;
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java
index ca6de31..1b112c2 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java
@@ -96,13 +96,7 @@
XMLModel model = document.getModel();
if (model == null)
return; // error
- if (model.isReinitializationNeeded()) {
- // we're may be looping. Even if not,
- // if we're going to be reinitialized,
- // no need to worry about document type
- // this pass.
- return;
- }
+
IFile file = getFile(model);
// find DOCTYPE delcaration and Public ID
@@ -241,14 +235,17 @@
}
return publicId;
}
-
+
private IFile getFile(IStructuredModel model) {
+ IFile result = null;
String location = model.getBaseLocation();
- IPath path = new Path(location);
- if (!path.toFile().exists() && path.segmentCount() > 1) {
- return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (location != null) {
+ IPath path = new Path(location);
+ if (!path.toFile().exists() && path.segmentCount() > 1) {
+ result = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ }
}
- return null;
+ return result;
}
/**
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java
index dbb4a37..994e939 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java
@@ -49,8 +49,11 @@
/**
* ModelQueryAdapterFactoryForHTML constructor comment.
- * @param adapterKey java.lang.Object
- * @param registerAdapters boolean
+ *
+ * @param adapterKey
+ * java.lang.Object
+ * @param registerAdapters
+ * boolean
*/
public ModelQueryAdapterFactoryForHTML(Object adapterKey, boolean registerAdapters) {
super(adapterKey, registerAdapters);
@@ -69,12 +72,14 @@
IStructuredModel model = stateNotifier = xmlNode.getModel();
stateNotifier.addModelStateListener(this);
String baseLocation = null;
- File file = new Path(model.getBaseLocation()).toFile();
- if(file.exists()) {
- baseLocation = file.getAbsolutePath();
- }
- else {
- baseLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(model.getBaseLocation()).toString();
+ String modelsBaseLocation = model.getBaseLocation();
+ if (modelsBaseLocation != null) {
+ File file = new Path(modelsBaseLocation).toFile();
+ if (file.exists()) {
+ baseLocation = file.getAbsolutePath();
+ } else {
+ baseLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(modelsBaseLocation).toString();
+ }
}
if (Debug.displayInfo)
System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + baseLocation); //$NON-NLS-1$
@@ -92,7 +97,7 @@
protected void updateResolver(IStructuredModel model) {
String baseLocation = model.getBaseLocation();
IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
- if(baseFile != null) {
+ if (baseFile != null) {
baseLocation = baseFile.getLocation().toString();
}
modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver()));
@@ -111,7 +116,8 @@
}
/**
- * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel, boolean)
+ * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel,
+ * boolean)
*/
public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
}
@@ -123,7 +129,8 @@
}
/**
- * @see IModelStateListener#modelResourceMoved(IStructuredModel, IStructuredModel)
+ * @see IModelStateListener#modelResourceMoved(IStructuredModel,
+ * IStructuredModel)
*/
public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
stateNotifier.removeModelStateListener(this);
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
index 95a2e20..87a1fe8 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
@@ -21,11 +21,13 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TypedRegion;
import org.eclipse.wst.common.encoding.EncodingMemento;
import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
import org.eclipse.wst.sse.core.events.NewModelEvent;
import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
+import org.eclipse.wst.sse.core.internal.Logger;
import org.eclipse.wst.sse.core.internal.NotImplementedException;
import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
import org.eclipse.wst.sse.core.parser.RegionParser;
@@ -229,7 +231,9 @@
}
public ITypedRegion getPartition(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
+ Logger.log(Logger.WARNING, "An instance of MinimalDocument was asked for its partition, sometime indicating a deleted region was being accessed.");
+ return new TypedRegion(0,0, "undefined");
+ //throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
}
public String[] getPositionCategories() {
diff --git a/bundles/org.eclipse.wst.xml.core/plugin.xml b/bundles/org.eclipse.wst.xml.core/plugin.xml
index 499c912..4f83043 100644
--- a/bundles/org.eclipse.wst.xml.core/plugin.xml
+++ b/bundles/org.eclipse.wst.xml.core/plugin.xml
@@ -99,16 +99,16 @@
<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
- priority="high"
+ file-extensions="xml,xsl,xslt,dadx,wsdl,nst,xmi,xsd,exsd"
+ priority="low"
name="%XML_Content_Type_Extension_Element.name"
id="xmlsource"
base-type="org.eclipse.core.runtime.xml"
- default-charset="UTF-8">
+ default-charset="UTF-8"
+ alias-for="org.eclipse.core.runtime.xml"
+ >
<describer class="org.eclipse.wst.xml.core.contenttype.ContentDescriberForXML"/>
</content-type>
- <file-association
- content-type="org.eclipse.core.runtime.xml"
- file-extensions="xsl,xslt,dadx,wsdl,nst,xmi,xsd,exsd"/>
</extension>
</plugin>
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java
index a78089e..7895184 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java
@@ -12,14 +12,194 @@
*******************************************************************************/
package org.eclipse.wst.xml.core.contenttype;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentDescriber;
+import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.ITextContentDescriber;
-import org.eclipse.wst.common.encoding.AbstractContentDescriber;
+import org.eclipse.wst.common.encoding.EncodingMemento;
+import org.eclipse.wst.common.encoding.IContentDescriptionExtended;
import org.eclipse.wst.common.encoding.IResourceCharsetDetector;
-public class ContentDescriberForXML extends AbstractContentDescriber implements ITextContentDescriber {
+public class ContentDescriberForXML implements ITextContentDescriber {
+ private final static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT};
+
protected IResourceCharsetDetector getDetector() {
return new XMLResourceEncodingDetector();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.content.IContentDescriber#describe(java.io.InputStream,
+ * org.eclipse.core.runtime.content.IContentDescription)
+ */
+ public int describe(InputStream contents, IContentDescription description) throws IOException {
+ int result = IContentDescriber.INDETERMINATE;
+
+ calculateSupportedOptions(contents, description);
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.content.ITextContentDescriber#describe(java.io.Reader,
+ * org.eclipse.core.runtime.content.IContentDescription)
+ */
+ public int describe(Reader contents, IContentDescription description) throws IOException {
+ int result = IContentDescriber.INDETERMINATE;
+
+ calculateSupportedOptions(contents, description);
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.content.IContentDescriber#getSupportedOptions()
+ */
+ public QualifiedName[] getSupportedOptions() {
+
+ return SUPPORTED_OPTIONS;
+ }
+
+ private void calculateSupportedOptions(InputStream contents, IContentDescription description) throws IOException {
+ if (isRelevent(description)) {
+ IResourceCharsetDetector detector = getDetector();
+ detector.set(contents);
+ handleCalculations(description, detector);
+ }
+ }
+
+ /**
+ * @param contents
+ * @param description
+ * @throws IOException
+ */
+ private void calculateSupportedOptions(Reader contents, IContentDescription description) throws IOException {
+ if (isRelevent(description)) {
+ IResourceCharsetDetector detector = getDetector();
+ detector.set(contents);
+ handleCalculations(description, detector);
+ }
+ }
+
+ private void handleDetectedSpecialCase(IContentDescription description, Object detectedCharset, Object javaCharset) {
+ // since equal, we don't need to add, but if our detected version is
+ // different than
+ // javaCharset, then we should add it. This will happen, for example,
+ // if there's
+ // differences in case, or differences due to override properties
+ if (detectedCharset != null) {
+ // if (!detectedCharset.equals(javaCharset)) {
+ // description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET,
+ // detectedCharset);
+ // }
+
+ // Once we detected a charset, we should set the property even
+ // though it's the same as javaCharset
+ // because there are clients that rely on this property to
+ // determine if the charset is actually detected in file or not.
+ description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, detectedCharset);
+ }
+ }
+
+ /**
+ * @param description
+ * @return
+ */
+ private boolean isRelevent(IContentDescription description) {
+ boolean result = false;
+ if (description == null)
+ result = false;
+ else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK))
+ result = true;
+ else if (description.isRequested(IContentDescription.CHARSET))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.DETECTED_CHARSET))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET))
+ result = true;
+ // else if
+ // (description.isRequested(IContentDescriptionExtended.ENCODING_MEMENTO))
+ // result = true;
+ return result;
+ }
+
+ /**
+ * @param description
+ * @param detector
+ * @throws IOException
+ */
+ protected void handleCalculations(IContentDescription description, IResourceCharsetDetector detector) throws IOException {
+ // note: if we're asked for one, we set them all. I need to be sure if
+ // called
+ // mulitiple times (one for each, say) that we don't waste time
+ // processing same
+ // content again.
+ EncodingMemento encodingMemento = detector.getEncodingMemento();
+ // TODO: I need to verify to see if this BOM work is always done
+ // by text type.
+ Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
+ if (detectedByteOrderMark != null) {
+ Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
+ // not sure why would ever be different, so if is different, may
+ // need to "push" up into base.
+ if (!detectedByteOrderMark.equals(existingByteOrderMark))
+ description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
+ }
+
+
+ if (!encodingMemento.isValid()) {
+ // note: after setting here, its the mere presence of
+ // IContentDescriptionExtended.UNSUPPORTED_CHARSET
+ // in the resource's description that can be used to determine if
+ // invalid
+ // in those cases, the "detected" property contains an
+ // "appropriate default" to use.
+ description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
+ description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
+ }
+
+ Object detectedCharset = encodingMemento.getDetectedCharsetName();
+ Object javaCharset = encodingMemento.getJavaCharsetName();
+
+ // we always include detected, if its different than java
+ handleDetectedSpecialCase(description, detectedCharset, javaCharset);
+
+ if (javaCharset != null) {
+ Object existingCharset = description.getProperty(IContentDescription.CHARSET);
+ if (javaCharset.equals(existingCharset)) {
+ handleDetectedSpecialCase(description, detectedCharset, javaCharset);
+ } else {
+ // we may need to add what we found, but only need to add
+ // if different from default.the
+ Object defaultCharset = getDetector().getSpecDefaultEncoding();
+ if (defaultCharset != null) {
+ if (!defaultCharset.equals(javaCharset)) {
+ description.setProperty(IContentDescription.CHARSET, javaCharset);
+ }
+ } else {
+ // assuming if there is no spec default, we always need to
+ // add, I'm assuming
+ description.setProperty(IContentDescription.CHARSET, javaCharset);
+ }
+ }
+ }
+
+ // avoid adding anything if not absolutly needed, since always
+ // "cached" per session
+ // description.setProperty(IContentDescriptionExtended.ENCODING_MEMENTO,
+ // encodingMemento);
+ }
+
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
index 5e54f74..4a41ef8 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
@@ -263,9 +263,11 @@
// unlike 'resfresh', 'reinitialize' finishes loop
// and flushes remaining notification que before
// actually reinitializing.
- // FUTURE: perhaps all "handleRefresh" should be changed
- // to "reinit needede"?
- this.setReinitializeNeeded(true);
+ // ISSUE: should reinit be used instead of handlerefresh?
+ // this.setReinitializeNeeded(true);
+ if (this.active != null || getModelNotifier().isChanging())
+ return; // defer
+ handleRefresh();
}
protected void editableChanged(Node node) {