use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project liferay-ide by liferay.
the class AlloyJSPDocumentLoader method newEncodedDocument.
@Override
protected IEncodedDocument newEncodedDocument() {
IEncodedDocument retval = super.newEncodedDocument();
if (retval instanceof IStructuredDocument) {
IStructuredDocument doc = (IStructuredDocument) retval;
RegionParser parser = doc.getParser();
if (parser instanceof BlockTagParser) {
BlockTagParser blockParser = (BlockTagParser) parser;
BlockMarker bm = new BlockMarker("aui:script", null, DOMRegionContext.BLOCK_TEXT, false);
blockParser.addBlockMarker(bm);
}
}
return retval;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class AbstractDocumentLoader method createNewStructuredDocument.
public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException {
if (filename == null && inputStream == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("can not have both null filename and inputstream");
}
IEncodedDocument structuredDocument = createNewStructuredDocument();
CodedReaderCreator codedReaderCreator = getCodedReaderCreator();
try {
codedReaderCreator.set(filename, inputStream);
codedReaderCreator.setEncodingRule(encodingRule);
fEncodingMemento = codedReaderCreator.getEncodingMemento();
fFullPreparedReader = codedReaderCreator.getCodedReader();
structuredDocument.setEncodingMemento(fEncodingMemento);
setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
} catch (CoreException e) {
// impossible in this context
throw new Error(e);
} finally {
if (fFullPreparedReader != null) {
fFullPreparedReader.close();
}
}
return structuredDocument;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class JSPDocumentLoader method createNewStructuredDocument.
public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream) throws UnsupportedEncodingException, IOException {
if (filename == null && inputStream == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("can not have both null filename and inputstream");
}
IEncodedDocument structuredDocument = createNewStructuredDocument();
CodedReaderCreator codedReaderCreator = new CodedReaderCreator();
try {
codedReaderCreator.set(filename, inputStream);
fFullPreparedReader = codedReaderCreator.getCodedReader();
fEncodingMemento = codedReaderCreator.getEncodingMemento();
structuredDocument.setEncodingMemento(fEncodingMemento);
// the fact that file is null means this method/code path is no
// good for JSP fragments
EmbeddedTypeHandler embeddedType = getEmbeddedType((IFile) null);
fFullPreparedReader.reset();
if (embeddedType != null)
embeddedType.initializeParser(((IStructuredDocument) structuredDocument).getParser());
setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
} catch (CoreException e) {
// impossible in this context
throw new Error(e);
} finally {
if (fFullPreparedReader != null) {
fFullPreparedReader.close();
}
}
return structuredDocument;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createUnManagedStructuredModelFor.
/**
* Conveience method. It depends on the loaders newModel method to return
* an appropriate StrucuturedModel appropriately initialized.
*/
public IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException {
IStructuredModel result = null;
result = createUnManagedEmptyModelFor(iFile);
IDocumentLoader loader = result.getModelHandler().getDocumentLoader();
IEncodedDocument document = loader.createNewStructuredDocument(iFile);
result.getStructuredDocument().setText(this, document.get());
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class AbstractModelLoader method load.
public void load(String filename, InputStream inputStream, IStructuredModel model, String junk, String dummy) throws UnsupportedEncodingException, java.io.IOException {
long memoryUsed = 0;
if (DEBUG) {
memoryUsed = computeMem();
// $NON-NLS-1$
System.out.println("measuring heap memory for " + filename);
// System.out.println("heap memory used before load: " +
// memoryUsed);
}
// during an initial load, we expect the olddocument to be empty
// during re-load, however, it would be full.
IEncodedDocument newstructuredDocument = null;
IEncodedDocument oldStructuredDocument = model.getStructuredDocument();
// get new document
if (inputStream == null) {
newstructuredDocument = getDocumentLoader().createNewStructuredDocument();
} else {
newstructuredDocument = getDocumentLoader().createNewStructuredDocument(filename, inputStream);
}
if (DEBUG) {
long memoryAtEnd = computeMem();
// System.out.println("heap memory used after loading new
// document: " + memoryAtEnd);
// $NON-NLS-1$
System.out.println(" heap memory implied used by document: " + (memoryAtEnd - memoryUsed));
}
// TODO: need to straighten out IEncodedDocument mess
if (newstructuredDocument instanceof IStructuredDocument) {
transformInstance((IStructuredDocument) oldStructuredDocument, (IStructuredDocument) newstructuredDocument);
} else {
// we don't really expect this case, just included for safety
oldStructuredDocument.set(newstructuredDocument.get());
}
// original hack
// model.setStructuredDocument((IStructuredDocument)
// structuredDocument);
// ((IStructuredDocument) structuredDocument).fireNewDocument(this);
documentLoaderInstance = null;
// documentLoaderInstance = null;
if (DEBUG) {
long memoryAtEnd = computeMem();
// System.out.println("heap memory used after setting to model: "
// + memoryAtEnd);
// $NON-NLS-1$
System.out.println(" heap memory implied used by document and model: " + (memoryAtEnd - memoryUsed));
}
}
Aggregations