use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.
the class StructuredTextViewerConfiguration method getContentFormatter.
/**
* Returns the content formatter ready to be used with the given source
* viewer.
* <p>
* It is not recommended that clients override this method as it may
* become <code>final</code> in the future and replaced by an extensible
* framework.
* </p>
*
* @param sourceViewer
* the source viewer to be configured by this configuration
* @return a content formatter or <code>null</code> if formatting should
* not be supported
*/
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
// try to use the StructuredTextMultiPassContentFormatter so that it
// picks up any additional formatting strategies contributed via the
// editorConfiguration extension point
IContentFormatter formatter = null;
if (sourceViewer != null) {
IDocument document = sourceViewer.getDocument();
if (document instanceof IDocumentExtension3) {
String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
IDocumentPartitioner partitioner = ((IDocumentExtension3) document).getDocumentPartitioner(partitioning);
if (partitioner instanceof StructuredTextPartitioner) {
String defaultPartitionType = ((StructuredTextPartitioner) partitioner).getDefaultPartitionType();
formatter = new StructuredTextMultiPassContentFormatter(partitioning, defaultPartitionType);
}
}
}
return formatter;
}
use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.
the class PageDirectiveAdapterImpl method setLanguage.
/**
* This is public access method, used especially from loader, for JSP
* Fragment support.
*/
public void setLanguage(String newLanguage) {
this.cachedLanguage = newLanguage;
IDocumentPartitioner partitioner = ((IDocumentExtension3) model.getStructuredDocument()).getDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING);
if (partitioner instanceof StructuredTextPartitionerForJSP) {
((StructuredTextPartitionerForJSP) partitioner).setLanguage(newLanguage);
}
}
use of org.eclipse.jface.text.IDocumentPartitioner in project liferay-ide by liferay.
the class LiferayPropertiesContentAssistProcessor method _getPartitioner.
@SuppressWarnings("restriction")
private IDocumentPartitioner _getPartitioner(IDocument document) {
IDocumentPartitioner retval = null;
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 doc3 = (IDocumentExtension3) document;
retval = doc3.getDocumentPartitioner(org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING);
}
return retval;
}
use of org.eclipse.jface.text.IDocumentPartitioner in project liferay-ide by liferay.
the class LiferayPropertiesContentAssistProcessor method computeCompletionProposals.
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
ICompletionProposal[] retval = null;
String currentPartitionType = null;
IDocument document = viewer.getDocument();
IDocumentPartitioner partitioner = _getPartitioner(document);
if (partitioner != null) {
ITypedRegion p = partitioner.getPartition(offset);
if (p != null) {
currentPartitionType = p.getType();
}
}
if ((currentPartitionType != null) && currentPartitionType.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
// now we need to check to see if we have a partial key
int rewindOffset = _rewindOffsetToNearestNonDefaultPartition(partitioner, offset);
String partialKey = _getPartialKey(document, rewindOffset, offset);
List<ICompletionProposal> proposals = new ArrayList<>();
if (_propKeys != null) {
for (PropKey key : _propKeys) {
if ((partialKey != null) && key.getKey().startsWith(partialKey)) {
proposals.add(new PropertyCompletionProposal(key.getKey(), key.getComment(), offset, rewindOffset));
}
}
}
retval = proposals.toArray(new ICompletionProposal[0]);
}
return retval;
}
use of org.eclipse.jface.text.IDocumentPartitioner in project abstools by abstools.
the class ABSDocumentProvider method createDocument.
@Override
protected IDocument createDocument(Object element) throws CoreException {
// Avoid ResourceException if you open a file that has disappeared.
if (isDeleted(element))
return super.createEmptyDocument();
IDocument document = super.createDocument(element);
if (document == null) {
if (element instanceof IURIEditorInput) {
IURIEditorInput ei = (IURIEditorInput) element;
document = createEmptyDocument();
InputStream is = null;
try {
is = ei.getURI().toURL().openStream();
setDocumentContent(document, is, getEncoding(element));
} catch (IOException ex) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "ABS Editor", ex));
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ex) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "ABS Editor", ex));
}
}
}
} else
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Don't know how to open " + element.toString()));
}
ABSPartitionScanner scanner = new ABSPartitionScanner();
IDocumentPartitioner partitioner = new FastPartitioner(scanner, PARTITION_TYPES);
document.setDocumentPartitioner(partitioner);
partitioner.connect(document);
return document;
}
Aggregations