/*******************************************************************************
* Copyright (c) 2008 Scott Stanchfield, based on ANTLR-Eclipse plugin
* by Torsten Juergeleit.
* 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
* Torsten Juergeleit - original ANTLR Eclipse plugin
* Scott Stanchfield - modifications for ANTXR
*******************************************************************************/
package com.javadude.antxr.eclipse.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 com.javadude.antxr.eclipse.ui.editor.text.PartitionScanner;
/**
* This class provides the IDocuments used by ANTXR editors.
* These IDocuments have an ANTXR-aware partition scanner (multi-line comments)
* attached.
*/
public class AntxrDocumentProvider extends FileDocumentProvider {
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(java.lang.Object)
*/
protected IDocument createDocument(Object anElement) throws CoreException {
IDocument document = super.createDocument(anElement);
if (document != null) {
IDocumentPartitioner partitioner = new FastPartitioner(
new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
}
return document;
}
}