[87333] StructuredTextViewer should not be model-dependent
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java
index 50f1d6d..5cbaae2 100644
--- a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java
@@ -21,6 +21,7 @@
import org.eclipse.wst.sse.core.INodeAdapter;
import org.eclipse.wst.sse.core.IStructuredModel;
import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.ui.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.xml.core.document.XMLNode;
@@ -44,14 +45,12 @@
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) {
IndexedRegion indexedNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, documentPosition + fDocumentOffset);
- IndexedRegion keyIndexedNode = null;
XMLNode xNode = null;
XMLNode parent = null;
- IStructuredModel cssModel = null;
CSSProposalArranger arranger = null;
// bail if we couldn't get an indexed node
- //if(indexedNode == null) return new ICompletionProposal[0];
+ // if(indexedNode == null) return new ICompletionProposal[0];
if (indexedNode instanceof XMLNode) {
xNode = (XMLNode) indexedNode;
parent = (XMLNode) xNode.getParentNode();
@@ -60,82 +59,102 @@
// case
if (xNode != null && xNode.getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
// now we know the cursor is in a <style> tag w/out region
- cssModel = getCSSModel(xNode);
- if (cssModel == null)
- return new ICompletionProposal[0];
-
- // adjust offsets for embedded style
- int offset = documentPosition;
- int pos = 0;
- keyIndexedNode = cssModel.getIndexedRegion(pos);
- if (keyIndexedNode == null) {
- keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ IStructuredModel cssModel = getCSSModel(xNode);
+ if (cssModel != null) {
+ // adjust offsets for embedded style
+ int offset = documentPosition;
+ int pos = 0;
+ IndexedRegion keyIndexedNode = cssModel.getIndexedRegion(pos);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
}
- arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
-
- } else if (parent != null && parent.getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
+ }
+ else if (parent != null && parent.getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
// now we know the cursor is in a <style> tag with a region
// use the parent because that will be the <style> tag
- cssModel = getCSSModel(parent);
- if (cssModel == null)
- return new ICompletionProposal[0];
-
- // adjust offsets for embedded style
- int offset = indexedNode.getStartOffset();
- int pos = documentPosition - offset;
- keyIndexedNode = cssModel.getIndexedRegion(pos);
- if (keyIndexedNode == null) {
- keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ IStructuredModel cssModel = getCSSModel(parent);
+ if (cssModel != null) {
+ // adjust offsets for embedded style
+ int offset = indexedNode.getStartOffset();
+ int pos = documentPosition - offset;
+ IndexedRegion keyIndexedNode = cssModel.getIndexedRegion(pos);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
}
- arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
- } else if (indexedNode instanceof XMLNode) {
+ }
+ else if (indexedNode instanceof XMLNode) {
// get model for node w/ style attribute
- cssModel = getCSSModel((XMLNode) indexedNode);
- } else if (indexedNode instanceof ICSSNode) {
+ IStructuredModel cssModel = getCSSModel((XMLNode) indexedNode);
+ if (cssModel != null) {
+ IndexedRegion keyIndexedNode = cssModel.getIndexedRegion(documentPosition - fDocumentOffset);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ if (keyIndexedNode instanceof ICSSNode) {
+ // inline style for a tag, not embedded
+ arranger = new CSSProposalArranger(documentPosition, (ICSSNode) keyIndexedNode, fDocumentOffset, fQuote);
+ }
+ }
+ }
+ else if (indexedNode instanceof ICSSNode) {
// when editing external CSS using CSS Designer, ICSSNode is
// passed.
ICSSDocument cssdoc = ((ICSSNode) indexedNode).getOwnerDocument();
if (cssdoc != null) {
- cssModel = cssdoc.getModel();
+ IStructuredModel cssModel = cssdoc.getModel();
+ if (cssModel != null) {
+ IndexedRegion keyIndexedNode = cssModel.getIndexedRegion(documentPosition - fDocumentOffset);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ if (keyIndexedNode instanceof ICSSNode) {
+ // inline style for a tag, not embedded
+ arranger = new CSSProposalArranger(documentPosition, (ICSSNode) keyIndexedNode, fDocumentOffset, fQuote);
+ }
+ }
}
- } else if (indexedNode == null && isViewerEmpty(viewer) && viewer instanceof StructuredTextViewer) {
+ }
+ else if (indexedNode == null && isViewerEmpty(viewer)) {
// the top of empty CSS Document
- IStructuredModel model = ((StructuredTextViewer) viewer).getModel();
- if (model instanceof ICSSModel) {
- cssModel = (ICSSModel) model;
+ IStructuredModel cssModel = null;
+ try {
+ cssModel = StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+ if (cssModel instanceof ICSSModel) {
+ IndexedRegion keyIndexedNode = cssModel.getIndexedRegion(documentPosition - fDocumentOffset);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ if (keyIndexedNode instanceof ICSSNode) {
+ // inline style for a tag, not embedded
+ arranger = new CSSProposalArranger(documentPosition, (ICSSNode) keyIndexedNode, fDocumentOffset, fQuote);
+ }
+ }
+ }
+ finally {
+ if (cssModel != null)
+ cssModel.releaseFromRead();
}
}
- if (cssModel == null)
- return new ICompletionProposal[0];
+ ICompletionProposal[] proposals = new ICompletionProposal[0];
+ if (arranger != null) {
+ fDocumentOffset = 0;
+ proposals = arranger.getProposals();
- keyIndexedNode = cssModel.getIndexedRegion(documentPosition - fDocumentOffset);
- if (keyIndexedNode == null) {
- keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ // add end tag if parent is not closed
+ ICompletionProposal endTag = XMLContentAssistUtilities.computeXMLEndTagProposal(viewer, documentPosition, indexedNode, HTML40Namespace.ElementName.STYLE, SharedXMLEditorPluginImageHelper.IMG_OBJ_TAG_GENERIC); //$NON-NLS-1$
+ if (endTag != null) {
+ ICompletionProposal[] plusOne = new ICompletionProposal[proposals.length + 1];
+ System.arraycopy(proposals, 0, plusOne, 1, proposals.length);
+ plusOne[0] = endTag;
+ proposals = plusOne;
+ }
}
-
- if (!(keyIndexedNode instanceof ICSSNode)) {
- return new ICompletionProposal[0];
- }
-
- if (arranger == null) {
- // if it's null at this point, it must be inline style for a tag,
- // not embedded
- arranger = new CSSProposalArranger(documentPosition, (ICSSNode) keyIndexedNode, fDocumentOffset, fQuote);
- }
- fDocumentOffset = 0;
- ICompletionProposal[] temp = arranger.getProposals();
-
- // add end tag if parent is not closed
- ICompletionProposal endTag = XMLContentAssistUtilities.computeXMLEndTagProposal(viewer, documentPosition, indexedNode, HTML40Namespace.ElementName.STYLE, SharedXMLEditorPluginImageHelper.IMG_OBJ_TAG_GENERIC); //$NON-NLS-1$
- if (endTag == null)
- return temp;
- else {
- ICompletionProposal[] plusOne = new ICompletionProposal[temp.length + 1];
- System.arraycopy(temp, 0, plusOne, 1, temp.length);
- plusOne[0] = endTag;
- return plusOne;
- }
+ return proposals;
}
/**
@@ -160,18 +179,18 @@
* @param indexedNode
* @return IStructuredModel
*/
- // private IStructuredModel getCSSModel(IndexedRegion indexedNode) {
- // if (indexedNode == null) return null;
- // Node node = (Node)indexedNode;
- // INodeNotifier notifier = (INodeNotifier)node.getParentNode();
- // if (notifier == null) return null;
- // INodeAdapter adapter =
+ // private IStructuredModel getCSSModel(IndexedRegion indexedNode) {
+ // if (indexedNode == null) return null;
+ // Node node = (Node)indexedNode;
+ // INodeNotifier notifier = (INodeNotifier)node.getParentNode();
+ // if (notifier == null) return null;
+ // INodeAdapter adapter =
// StyleAdapterFactory.getInstance().adapt(notifier);
- // if (adapter == null || !(adapter instanceof CSSModelAdapter)) return
+ // if (adapter == null || !(adapter instanceof CSSModelAdapter)) return
// null;
- // CSSModelAdapter modelAdapter = (CSSModelAdapter)adapter;
- // return modelAdapter.getModel();
- // }
+ // CSSModelAdapter modelAdapter = (CSSModelAdapter)adapter;
+ // return modelAdapter.getModel();
+ // }
/**
* Returns the CSSmodel for a given XML node.
*
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
index d2c990f..a7e0b3f 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
@@ -177,8 +177,6 @@
// changed.
structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file);
- structuredModel.aboutToChangeModel();
-
// format
formatModel(structuredModel);
@@ -188,7 +186,6 @@
} finally {
//ensureClosed(outputStream, null);
// release from model manager
- structuredModel.changedModel();
if (structuredModel != null) {
structuredModel.releaseFromEdit();
}
@@ -287,66 +284,73 @@
public void formatModel(IStructuredModel structuredModel, int start, int length) {
if (structuredModel != null) {
- if (start == 0 && length == structuredModel.getStructuredDocument().getLength())
- setFormatWithSiblingIndent(structuredModel, false);
- else
- setFormatWithSiblingIndent(structuredModel, true);
-
- if (start >= 0 && length >= 0 && start + length <= structuredModel.getStructuredDocument().getLength()) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- Node firstNode = (Node) activeNodes.firstElement();
- Node lastNode = (Node) activeNodes.lastElement();
-
- boolean done = false;
- Node eachNode = firstNode;
- Node nextNode = null;
- // TODO: we should be able to call something like
- // sequentialRewrite, but
- // doesn't work for
- // our case, since we do "gets" during reparsing, so makes
- // sequential rewrite
- // store actually
- // less efficient than gap store. Someday we need our own
- // gap store, that
- // handles
- // structured text more efficiently. I thought I'd leave
- // this commented out
- // code here
- // as a reminder.
- // try {
- // structuredModel.getStructuredDocument().startSequentialRewrite(false);
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before format because eachNode
- // may
- // be deleted,
- // for example when it's an empty text node
- nextNode = eachNode.getNextSibling();
-
- // format each node
- formatNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during format
- eachNode = eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
+ try {
+ // whenever formatting model, fire abouttochange/modelchanged
+ structuredModel.aboutToChangeModel();
+ if (start == 0 && length == structuredModel.getStructuredDocument().getLength())
+ setFormatWithSiblingIndent(structuredModel, false);
+ else
+ setFormatWithSiblingIndent(structuredModel, true);
+
+ if (start >= 0 && length >= 0 && start + length <= structuredModel.getStructuredDocument().getLength()) {
+ Vector activeNodes = getActiveNodes(structuredModel, start, length);
+ if (activeNodes.size() > 0) {
+ Node firstNode = (Node) activeNodes.firstElement();
+ Node lastNode = (Node) activeNodes.lastElement();
+
+ boolean done = false;
+ Node eachNode = firstNode;
+ Node nextNode = null;
+ // TODO: we should be able to call something like
+ // sequentialRewrite, but
+ // doesn't work for
+ // our case, since we do "gets" during reparsing, so makes
+ // sequential rewrite
+ // store actually
+ // less efficient than gap store. Someday we need our own
+ // gap store, that
+ // handles
+ // structured text more efficiently. I thought I'd leave
+ // this commented out
+ // code here
+ // as a reminder.
+ // try {
+ // structuredModel.getStructuredDocument().startSequentialRewrite(false);
+ while (!done) {
+ // update "done"
+ done = (eachNode == lastNode);
+
+ // get next sibling before format because eachNode
+ // may
+ // be deleted,
+ // for example when it's an empty text node
+ nextNode = eachNode.getNextSibling();
+
+ // format each node
+ formatNode(eachNode);
+
+ // update each node
+ if (nextNode != null && nextNode.getParentNode() == null)
+ // nextNode is deleted during format
+ eachNode = eachNode.getNextSibling();
+ else
+ eachNode = nextNode;
+
+ // This should not be needed, but just in case
+ // something went wrong with with eachNode.
+ // We don't want an infinite loop here.
+ if (eachNode == null)
+ done = true;
+ }
+ // }
+ // finally {
+ // structuredModel.getStructuredDocument().stopSequentialRewrite();
+ // }
}
- // }
- // finally {
- // structuredModel.getStructuredDocument().stopSequentialRewrite();
- // }
}
+ } finally {
+ // always make sure to fire changedmodel when done
+ structuredModel.changedModel();
}
}
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
index 7980cd0..039eba7 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
@@ -59,9 +59,6 @@
import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.IChangeRulerColumn;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
@@ -121,12 +118,10 @@
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.IModelLifecycleListener;
import org.eclipse.wst.sse.core.IModelStateListenerExtended;
import org.eclipse.wst.sse.core.INodeNotifier;
import org.eclipse.wst.sse.core.IStructuredModel;
import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.ModelLifecycleEvent;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
import org.eclipse.wst.sse.core.internal.text.IExecutionDelegatable;
@@ -393,31 +388,6 @@
}
- private class ViewerModelLifecycleListener implements IModelLifecycleListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelLifecycleListener#processPostModelEvent(org.eclipse.wst.sse.core.ModelLifecycleEvent)
- */
- public void processPostModelEvent(ModelLifecycleEvent event) {
- // reconnect the textviewer on document instance change
- if (event.getType() == ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED) {
- if (getTextViewer() != null && getTextViewer().getControl() != null && !getTextViewer().getControl().isDisposed() && event.getModel().equals(getModel())) {
- getTextViewer().setModel(event.getModel(), getDocumentProvider().getAnnotationModel(getEditorInput()));
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelLifecycleListener#processPreModelEvent(org.eclipse.wst.sse.core.ModelLifecycleEvent)
- */
- public void processPreModelEvent(ModelLifecycleEvent event) {
- }
- }
-
protected final static char[] BRACKETS = {'{', '}', '(', ')', '[', ']'};
private static final long BUSY_STATE_DELAY = 1000;
public static final String CORE_SSE_ACTIVITY_ID = "com.ibm.wtp.xml.core"; //$NON-NLS-1$
@@ -477,7 +447,6 @@
protected DropTarget fDropTarget;
protected boolean fEditorDisposed = false;
private IEditorPart fEditorPart;
- private IModelLifecycleListener fInternalLifeCycleListener = new ViewerModelLifecycleListener();
private InternalModelStateListener fInternalModelStateListener;
protected MouseTracker fMouseTracker;
@@ -1104,7 +1073,6 @@
if (fStructuredModel.getStructuredDocument() != null)
fStructuredModel.getStructuredDocument().removeDocumentListener(this);
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
- fStructuredModel.removeModelLifecycleListener(fInternalLifeCycleListener);
}
if (getDocument() != null) {
@@ -1994,18 +1962,9 @@
* viewer-dependent.
*/
private void initializeSourceViewer() {
- IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
- if (getTextViewer() != null)
- getTextViewer().setModel(getModel(), annotationModel);
-
if (getViewerSelectionManager() != null)
getViewerSelectionManager().setModel(getModel());
- // workaround for bugzilla#56801
- // updates/reinstalls QuickDiff because some QuickDiff info is lost
- // when SourceViewer.setModel/setDocument is called
- updateDiffer();
-
computeAndSetDoubleClickAction(getModel());
IAction contentAssistAction = getAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS);
@@ -2223,28 +2182,6 @@
}
/**
- * Remove the QuickDiff annotation model from the SourceViewer's
- * Annotation model if it exists
- */
- private void removeDiffer() {
- // get annotation model extension
- ISourceViewer viewer = getSourceViewer();
- if (viewer == null)
- return;
-
- IAnnotationModel m = viewer.getAnnotationModel();
- IAnnotationModelExtension model;
- if (m instanceof IAnnotationModelExtension)
- model = (IAnnotationModelExtension) m;
- else
- return;
-
- // remove the quick differ if it already exists in the annotation
- // model
- model.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- }
-
- /**
* both starts and resets the busy state timer
*/
private void resetBusyState() {
@@ -2411,7 +2348,6 @@
public void setModel(IStructuredModel newModel) {
Assert.isNotNull(getDocumentProvider());
if (fStructuredModel != null) {
- fStructuredModel.removeModelLifecycleListener(fInternalLifeCycleListener);
if (fStructuredModel.getStructuredDocument() != null) {
fStructuredModel.getStructuredDocument().removeDocumentListener(this);
}
@@ -2423,7 +2359,6 @@
fStructuredModel.getStructuredDocument().addDocumentListener(this);
}
fStructuredModel.addModelStateListener(getInternalModelStateListener());
- fStructuredModel.addModelLifecycleListener(fInternalLifeCycleListener);
}
// update() should be called whenever the model is
// set or changed
@@ -2441,7 +2376,6 @@
// setModel(newModel);
Assert.isNotNull(getDocumentProvider());
if (fStructuredModel != null) {
- fStructuredModel.removeModelLifecycleListener(fInternalLifeCycleListener);
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
if (fStructuredModel.getStructuredDocument() != null) {
fStructuredModel.getStructuredDocument().removeDocumentListener(this);
@@ -2456,7 +2390,6 @@
fStructuredModel.getStructuredDocument().addDocumentListener(this);
}
fStructuredModel.addModelStateListener(getInternalModelStateListener());
- fStructuredModel.addModelLifecycleListener(fInternalLifeCycleListener);
}
// update() should be called whenever the model is
// set or changed
@@ -2529,9 +2462,6 @@
* swapped)
*/
public void update() {
- IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
- if (getTextViewer() != null)
- getTextViewer().setModel(getModel(), annotationModel);
if (fOutlinePage != null && fOutlinePage instanceof StructuredTextEditorContentOutlinePage) {
ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
if (cfg instanceof StructuredContentOutlineConfiguration) {
@@ -2556,10 +2486,6 @@
fShowInTargetIds = createShowInTargetIds();
- // workaround for bugzilla#56801
- // updates/reinstalls QuickDiff because some QuickDiff info is lost
- // when SourceViewer.setModel/setDocument is called
- updateDiffer();
// setSourceViewerConfiguration() was called once
// in
// StructuredTextMultiPageEditorPart.createSourcePage()
@@ -2607,21 +2533,6 @@
updateMenuText();
}
- /**
- * Updates/reinstalls QuickDiff
- */
- private void updateDiffer() {
- // workaround for bugzilla#56801
- // updates/reinstalls QuickDiff because some QuickDiff info is lost
- // when SourceViewer.setModel/setDocument is called
-
- if (isChangeInformationShowing()) {
- showChangeInformation(false);
- removeDiffer();
- showChangeInformation(true);
- }
- }
-
private void updateEncodingMemento() {
boolean failed = false;
if (getModel() != null) {
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java
index 4f83647..ba61142 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java
@@ -58,7 +58,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.wst.sse.core.IStructuredModel;
import org.eclipse.wst.sse.core.IndexedRegion;
import org.eclipse.wst.sse.core.cleanup.StructuredContentCleanupHandler;
import org.eclipse.wst.sse.core.text.IStructuredDocument;
@@ -138,10 +137,6 @@
/** The most recent widget modification as document command */
private StructuredDocumentCommand fDocumentCommand = new StructuredDocumentCommand();
private IHighlighter fHighlighter;
- /**
- * @deprecated
- */
- private IStructuredModel fModel;
// TODO: never read locally
boolean fRememberedStateContentAssistInstalled;
@@ -203,19 +198,9 @@
}
break;
}
- case CONTENTASSIST_CONTEXT_INFORMATION : {
- return true;
- }
case QUICK_FIX : {
return isEditable();
}
- case INFORMATION : {
- // the fInformationPresenter may not be set yet but you DO
- // want information
- // (this needs to be set to TRUE so menu item can become
- // active)
- return true;
- }
case CLEANUP_DOCUMENT : {
return (fContentCleanupHandler != null && isEditable());
}
@@ -569,10 +554,6 @@
// begin recording
beginRecording(FORMAT_DOCUMENT_TEXT, FORMAT_DOCUMENT_TEXT, cursorPosition, selectionLength);
- // tell the model that we are about to make a big model
- // change
- aboutToChangeModel();
-
// format
IRegion region = getModelCoverage();
if (fContentFormatter instanceof IContentFormatterExtension) {
@@ -585,10 +566,6 @@
fContentFormatter.format(getDocument(), region);
}
} finally {
- // tell the model that we are done with the big model
- // change
- changedModel();
-
// end recording
selection = getTextWidget().getSelection();
cursorPosition = selection.x;
@@ -600,16 +577,12 @@
try {
// begin recording
beginRecording(FORMAT_ACTIVE_ELEMENTS_TEXT, FORMAT_ACTIVE_ELEMENTS_TEXT, cursorPosition, selectionLength);
-
- aboutToChangeModel();
-
+
// format
Point s = getSelectedRange();
IRegion region = new Region(s.x, s.y);
fContentFormatter.format(getDocument(), region);
} finally {
- changedModel();
-
// end recording
selection = getTextWidget().getSelection();
cursorPosition = selection.x;
@@ -622,18 +595,6 @@
}
}
- private void changedModel() {
- if (getModel() != null) {
- getModel().changedModel();
- }
- }
-
- private void aboutToChangeModel() {
- if (getModel() != null) {
- getModel().aboutToChangeModel();
- }
- }
-
private void endRecording(int cursorPosition, int selectionLength) {
IDocument doc = getDocument();
if (doc instanceof IStructuredDocument) {
@@ -724,13 +685,6 @@
return new ViewerSelectionManagerImpl(this);
}
- /**
- * @deprecated -- will be removed in future.
- */
- public IStructuredModel getModel() {
- return fModel;
- }
-
public ViewerSelectionManager getViewerSelectionManager() {
if (fViewerSelectionManager == null) {
@@ -764,8 +718,7 @@
fHighlighter.uninstall();
}
super.handleDispose();
- // todo: make this setModel(null)
- fModel = null;
+
Logger.trace("Source Editor", "StructuredTextViewer::handleDispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1076,14 +1029,15 @@
// notify highlighter
if (fHighlighter != null) {
fHighlighter.setDocument(structuredDocument);
- // fHighlighter.setModel(model);
}
// set document in the viewer-based undo manager
if (fUndoManager instanceof StructuredTextViewerUndoManager) {
((StructuredTextViewerUndoManager) fUndoManager).setDocument(structuredDocument);
}
-
+ // CaretEvent is not sent to ViewerSelectionManager after Save As.
+ // Need to notify ViewerSelectionManager here.
+ notifyViewerSelectionManager(getSelectedRange().x, getSelectedRange().y);
}
}
@@ -1107,31 +1061,6 @@
}
}
- public void setModel(IStructuredModel model) {
-
- setModel(model, null);
- }
-
- public void setModel(IStructuredModel model, IAnnotationModel annotationModel) {
- // due to various forms of init, sometimes
- // the same variable is set more than once
- // with the same data, causing unneccesary updates, so
- // we do nothing if someones' trying to set the same
- // model we already have
- //
- if ((fModel != null) && (fModel == model) && (getDocument() == model.getStructuredDocument())) {
- return;
- }
- fModel = model;
- if (model != null) {
- setDocument(model.getStructuredDocument(), annotationModel);
- }
-
- // CaretEvent is not sent to ViewerSelectionManager after Save As.
- // Need to notify ViewerSelectionManager here.
- notifyViewerSelectionManager(getSelectedRange().x, getSelectedRange().y);
- }
-
public void setViewerSelectionManager(ViewerSelectionManager viewerSelectionManager) {
// disconnect from old one