X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java index 4bad7d2..ec11f3c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java @@ -18,6 +18,8 @@ import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.rules.DefaultPartitioner; import org.eclipse.jface.text.rules.IPartitionTokenScanner; @@ -361,6 +363,24 @@ public class JavaTextTools { return partitioner; } + /** + * Sets up the Java document partitioner for the given document for the given partitioning. + * + * @param document the document to be set up + * @param partitioning the document partitioning + * @since 3.0 + */ + public void setupJavaDocumentPartitioner(IDocument document, String partitioning) { + IDocumentPartitioner partitioner= createDocumentPartitioner(); + if (document instanceof IDocumentExtension3) { + IDocumentExtension3 extension3= (IDocumentExtension3) document; + extension3.setDocumentPartitioner(partitioning, partitioner); + } else { + document.setDocumentPartitioner(partitioner); + } + partitioner.connect(document); + } + /** * Returns the names of the document position categories used by the document * partitioners created by this object to manage their partition information.