/*
* <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.gmf.internal.xpand.editor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.gmf.internal.xpand.editor.scan.XpandPartitionScanner;
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;
/**
* @author Sven Efftinge
*
*
*/
public class XpandDocumentProvider 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 XpandPartitionScanner(), new String[] {
XpandPartitionScanner.TAG, XpandPartitionScanner.COMMENT });
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
}
return document;
}
}