From e5a3701e14aaddcd7aaa17abe9a13a5f0f5ad546 Mon Sep 17 00:00:00 2001 From: david_williams Date: Wed, 9 Feb 2005 23:42:12 +0000 Subject: simple cleanup of unit tests and logged exceptions --- .../core/document/HTMLDocumentTypeAdapter.java | 21 +++++++--------- .../ModelQueryAdapterFactoryForHTML.java | 29 ++++++++++++++-------- 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'bundles/org.eclipse.wst.html.core') 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 ca6de3109a..1b112c286e 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 @@ public class HTMLDocumentTypeAdapter extends DocumentTypeAdapterImpl implements 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 @@ public class HTMLDocumentTypeAdapter extends DocumentTypeAdapterImpl implements } 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 dbb4a3768a..994e939b1f 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 @@ public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory impl /** * 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 @@ public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory impl 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 @@ public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory impl 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 @@ public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory impl } /** - * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel, boolean) + * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel, + * boolean) */ public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) { } @@ -123,7 +129,8 @@ public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory impl } /** - * @see IModelStateListener#modelResourceMoved(IStructuredModel, IStructuredModel) + * @see IModelStateListener#modelResourceMoved(IStructuredModel, + * IStructuredModel) */ public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) { stateNotifier.removeModelStateListener(this); -- cgit v1.2.3