diff options
Diffstat (limited to 'plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendDocumentProvider.java')
-rw-r--r-- | plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendDocumentProvider.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendDocumentProvider.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendDocumentProvider.java new file mode 100644 index 00000000..20f1079f --- /dev/null +++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendDocumentProvider.java @@ -0,0 +1,48 @@ +/* + * <copyright> + * + * Copyright (c) 2005-2006 Sven Efftinge and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sven Efftinge - Initial API and implementation + * + * </copyright> + */ +package org.eclipse.xtend.ui.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.jface.text.rules.FastPartitioner; +import org.eclipse.ui.editors.text.FileDocumentProvider; +import org.eclipse.xtend.ui.editor.scanning.XtendPartitionScanner; + +/** + * @author Sven Efftinge (http://www.efftinge.de) + * + * + */ +public class XtendDocumentProvider extends FileDocumentProvider { + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(java.lang.Object) + */ + @Override + protected IDocument createDocument(final Object element) throws CoreException { + final IDocument document = super.createDocument(element); + if (document != null) { + final IDocumentPartitioner partitioner = new FastPartitioner(new XtendPartitionScanner(), + new String[] { XtendPartitionScanner.COMMENT, XtendPartitionScanner.STRING_LIT }); + partitioner.connect(document); + document.setDocumentPartitioner(partitioner); + } + return document; + } + +}
\ No newline at end of file |