Simplify StructuredModelManager facade
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextEditorJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextEditorJSP.java
index 5c1d6d9..08a1c31 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextEditorJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextEditorJSP.java
@@ -90,7 +90,7 @@
IJavaElement[] elements = new IJavaElement[0];
// get JSP translation object for this viewer's document
- XMLModel xmlModel = (XMLModel) StructuredModelManager.getInstance().getModelManager().getExistingModelForRead(getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
try {
if(xmlModel != null) {
XMLDocument xmlDoc = xmlModel.getDocument();
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
index 4e6d8a1..ce5810d 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
@@ -65,7 +65,6 @@
import org.eclipse.wst.javascript.common.ui.taginfo.JavaScriptBestMatchHoverProcessor;
import org.eclipse.wst.javascript.common.ui.taginfo.JavaScriptInformationProvider;
import org.eclipse.wst.javascript.common.ui.taginfo.JavaScriptTagInfoHoverProcessor;
-import org.eclipse.wst.sse.core.IModelManager;
import org.eclipse.wst.sse.core.IStructuredModel;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
@@ -387,10 +386,6 @@
fInformationPresenter.uninstall();
}
- private IModelManager getModelManager() {
- return StructuredModelManager.getInstance().getModelManager();
- }
-
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fReconciler != null) {
// a reconciler should always be installed or disposed of
@@ -420,7 +415,7 @@
viewer = ((StructuredTextViewer) sourceViewer);
}
- IStructuredModel sModel = getModelManager().getExistingModelForRead(viewer.getDocument());
+ IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
try {
if (sModel != null) {
// check language (ContentTypeID)....
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java
index 555f9ce..85b3b3f 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java
@@ -14,7 +14,6 @@
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jst.jsp.ui.internal.Logger;
-import org.eclipse.wst.sse.core.IModelManager;
import org.eclipse.wst.sse.core.IStructuredModel;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.ui.StructuredDocumentCommand;
@@ -26,7 +25,7 @@
StructuredDocumentCommand structuredDocumentCommand = (StructuredDocumentCommand) command;
IStructuredModel model = null;
try {
- model = getModelManager().getExistingModelForRead(document);
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (model != null) {
if (structuredDocumentCommand.text != null) {
@@ -53,8 +52,4 @@
model.releaseFromRead();
}
}
-
- private IModelManager getModelManager() {
- return StructuredModelManager.getInstance().getModelManager();
- }
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
index 72bcf60..407d50f 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
@@ -28,7 +28,6 @@
import org.eclipse.jst.jsp.core.internal.java.JSPTranslation;
import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
import org.eclipse.jst.jsp.ui.internal.Logger;
-import org.eclipse.wst.sse.core.IModelManager;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.ui.IReleasable;
@@ -66,10 +65,6 @@
fResource = resource;
}
- private IModelManager getModelManager() {
- return StructuredModelManager.getInstance().getModelManager();
- }
-
/**
* Returns a list of completion proposals based on the
* specified location within the document that corresponds
@@ -85,7 +80,7 @@
if (viewer instanceof StructuredTextViewer)
fViewer = (StructuredTextViewer) viewer;
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(fViewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
XMLDocument xmlDoc = xmlModel.getDocument();
xmlModel.releaseFromRead();
if (fTranslationAdapter == null)
@@ -162,7 +157,7 @@
private boolean cursorInExpression() {
boolean inExpression = false;
IStructuredDocumentRegion sdRegion = null;
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(fViewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
XMLNode xmlNode = null;
xmlModel.releaseFromRead();
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
index b9bbda2..d750517 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
@@ -303,7 +303,7 @@
// a full Document and then adjust the offset numbers in the
// list of results.
IStructuredModel internalModel = null;
- IModelManager mmanager = StructuredModelManager.getInstance().getModelManager();
+ IModelManager mmanager = StructuredModelManager.getModelManager();
internalModel = mmanager.createUnManagedStructuredModelFor(IContentTypeIdentifier.ContentTypeID_JSP);
XMLNode xmlNode = null;
XMLModel xmlOuterModel = null;
@@ -602,10 +602,6 @@
fErrorMessage = errorMessage;
}
- private IModelManager getModelManager() {
- return StructuredModelManager.getInstance().getModelManager();
- }
-
/**
* This method is acting as a "catch all" for pulling together content
* assist proposals from different Processors when document partitioning
@@ -623,7 +619,7 @@
// check the actual partition type
String partitionType = getPartitionType((StructuredTextViewer) viewer, documentPosition);
- IStructuredModel sModel = getModelManager().getExistingModelForRead(viewer.getDocument());
+ IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
IStructuredDocument structuredDocument = sModel.getStructuredDocument();
sModel.releaseFromRead();
@@ -1035,7 +1031,7 @@
String partitionType = null;
IStructuredModel sModel = null;
try {
- sModel = getModelManager().getExistingModelForRead(viewer.getDocument());
+ sModel = StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
IDocument document = sModel.getStructuredDocument();
ITypedRegion regionType = document.getPartition(documentPosition);
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/correction/CorrectionProcessorJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/correction/CorrectionProcessorJSP.java
index 5e9e06d..0e3b6b9 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/correction/CorrectionProcessorJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/correction/CorrectionProcessorJSP.java
@@ -31,7 +31,6 @@
import org.eclipse.jst.jsp.core.internal.java.JSPTranslation;
import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.IModelManager;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
import org.eclipse.wst.sse.ui.StructuredTextViewer;
@@ -71,7 +70,7 @@
if (documentOffset >= pos.offset && documentOffset <= pos.offset + pos.length) {
IQuickFixProcessor processor = getQuickFixProcessorJSP();
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(viewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
XMLDocument xmlDoc = xmlModel.getDocument();
xmlModel.releaseFromRead();
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
@@ -114,7 +113,7 @@
try {
IQuickAssistProcessor processor = getQuickAssistProcessorJSP();
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(viewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
XMLDocument xmlDoc = xmlModel.getDocument();
xmlModel.releaseFromRead();
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
@@ -146,8 +145,4 @@
throw new SourceEditingRuntimeException();
}
}
-
- private IModelManager getModelManager() {
- return StructuredModelManager.getInstance().getModelManager();
- }
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java
index bc96181..beed352 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java
@@ -104,7 +104,7 @@
*/
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
// get JSP translation object for this viewer's document
- XMLModel xmlModel = (XMLModel) StructuredModelManager.getInstance().getModelManager().getExistingModelForRead(textViewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
try {
if(xmlModel != null) {
XMLDocument xmlDoc = xmlModel.getDocument();
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPDirectiveOpenOnJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPDirectiveOpenOnJSP.java
index 4da6ac0b..3c96be5 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPDirectiveOpenOnJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPDirectiveOpenOnJSP.java
@@ -17,6 +17,7 @@
import org.eclipse.jst.jsp.core.internal.java.JSPTranslation;
import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
import org.eclipse.wst.html.ui.openon.DefaultOpenOnHTML;
+import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.xml.core.document.XMLDocument;
import org.eclipse.wst.xml.core.document.XMLModel;
import org.w3c.dom.Attr;
@@ -57,7 +58,7 @@
*/
private JSPTranslation getJSPTranslation() {
// get JSP translation object for this action's editor's document
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
if (xmlModel != null) {
XMLDocument xmlDoc = xmlModel.getDocument();
xmlModel.releaseFromRead();
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPJavaOpenOnJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPJavaOpenOnJSP.java
index 3dcf87c..0538f60 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPJavaOpenOnJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/openon/JSPJavaOpenOnJSP.java
@@ -32,6 +32,7 @@
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.core.IStructuredModel;
+import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.util.ResourceUtil;
import org.eclipse.wst.sse.ui.openon.AbstractOpenOn;
import org.eclipse.wst.xml.core.document.XMLDocument;
@@ -53,7 +54,7 @@
*/
private JSPTranslation getJSPTranslation() {
// get JSP translation object for this action's editor's document
- XMLModel xmlModel = (XMLModel) getModelManager().getExistingModelForRead(getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
if (xmlModel != null) {
XMLDocument xmlDoc = xmlModel.getDocument();
xmlModel.releaseFromRead();
@@ -251,7 +252,7 @@
IStructuredModel model = null;
IFile file = null;
try {
- model = getModelManager().getExistingModelForRead(getDocument());
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
IFile[] files = ResourceUtil.getFilesFor(model);
int i = 0;
while (i < files.length && file == null) {
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
index 48aeec5..e77594b 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
@@ -99,7 +99,7 @@
}
protected void setupPicker(StyledTextColorPicker picker) {
- IModelManager mmanager = StructuredModelManager.getInstance().getModelManager();
+ IModelManager mmanager = StructuredModelManager.getModelManager();
picker.setParser(mmanager.createStructuredDocumentFor(IContentTypeIdentifier.ContentTypeID_JSP).getParser());
// create descriptions for hilighting types
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/taginfo/JSPJavaJavadocHover.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/taginfo/JSPJavaJavadocHover.java
index f38d2e4..76fe88f 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/taginfo/JSPJavaJavadocHover.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/taginfo/JSPJavaJavadocHover.java
@@ -29,7 +29,7 @@
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
// get JSP translation object for this viewer's document
- XMLModel xmlModel = (XMLModel) StructuredModelManager.getInstance().getModelManager().getExistingModelForRead(textViewer.getDocument());
+ XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
try {
if(xmlModel != null) {
XMLDocument xmlDoc = xmlModel.getDocument();