use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class WebResourceChangeHandler method initialize.
private void initialize() {
IStructuredModel xmlModel = getModel();
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
xmlModel.addModelLifecycleListener(this);
IStructuredDocument fJspDocument = xmlModel.getStructuredDocument();
if (fJspDocument != null) {
fJspDocument.addDocumentListener(this);
}
irritator = new ModelIrritantThread();
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class EMF2DOMSSEAdapter method getNewlineString.
protected String getNewlineString(Node node) {
/*
* We should always have IDOMNode, and IStructuredDocument, and
* consquently a valid "preferred" line delimiter, but just to be
* safe, we'll assign something by default.
*/
if (node instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode) node;
IStructuredDocument document = xmlNode.getStructuredDocument();
if (document != null) {
return document.getLineDelimiter();
}
}
return DOMUtilities.NEWLINE_STRING;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class FileBufferModelManager method getModel.
public IStructuredModel getModel(IFile file) {
if (file == null) {
// $NON-NLS-1$
Exception iae = new IllegalArgumentException("can not get/create a model without an IFile");
Logger.logException(iae);
return null;
}
IStructuredModel model = null;
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
try {
if (Logger.DEBUG_FILEBUFFERMODELMANAGEMENT) {
// $NON-NLS-1$
Logger.log(Logger.INFO, "FileBufferModelManager connecting to IFile " + file.getFullPath());
}
// see TextFileDocumentProvider#createFileInfo about why we use
// IFile#getFullPath
// here, not IFile#getLocation.
IPath location = file.getFullPath();
if (location != null) {
bufferManager.connect(location, LocationKind.IFILE, getProgressMonitor());
ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location, LocationKind.IFILE);
if (buffer != null) {
DocumentInfo info = (DocumentInfo) fDocumentMap.get(buffer.getDocument());
if (info != null) {
/*
* Note: "info" being null at this point is a slight
* error.
*
* The connect call from above (or at some time
* earlier in the session) would have notified the
* FileBufferMapper of the creation of the
* corresponding text buffer and created the
* DocumentInfo object for IStructuredDocuments.
*/
info.selfConnected = true;
info.locationKind = LocationKind.IFILE;
}
/*
* Check the document type. Although returning null for
* unknown documents would be fair, try to get a model if
* the document is at least a valid type.
*/
IDocument bufferDocument = buffer.getDocument();
if (bufferDocument instanceof IStructuredDocument) {
model = getModel((IStructuredDocument) bufferDocument);
} else {
/*
* 190768 - Quick diff marks do not disappear in the
* vertical ruler of JavaScript editor and
*
* 193805 - Changes are not thrown away when close
* with no save for files with no structured model
* associated with them (text files, javascript files,
* etc) in web project
*/
bufferManager.disconnect(location, LocationKind.IFILE, getProgressMonitor());
}
}
}
} catch (CoreException e) {
// $NON-NLS-1$
Logger.logException("Error getting model for " + file.getFullPath(), e);
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class ClearReadOnlyDelegate method run.
public void run(IAction action) {
ITextEditor editor = fEditor.getAdapter(ITextEditor.class);
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
if (document instanceof IStructuredDocument) {
((IStructuredDocument) document).clearReadOnly(0, document.getLength());
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class JSONArrayCreationTest method createEmptyArrayNotClosed.
@Test
public void createEmptyArrayNotClosed() throws Exception {
IJSONModel model = (IJSONModel) TestUtil.createModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
IJSONDocument document = model.getDocument();
assertNull(document.getFirstChild());
// Load JSON Array
structuredDocument.set("[");
assertNotNull(document.getFirstChild());
Assert.assertTrue(document.getFirstChild() instanceof IJSONArray);
// The JSON array is not closed.
IJSONArray array = (IJSONArray) document.getFirstChild();
Assert.assertFalse(array.isClosed());
}
Aggregations