| /********************************************************************** |
| Copyright (c) 2000, 2004 IBM Corp. and others. |
| All rights reserved. This program and the accompanying materials |
| are made available under the terms of the Common Public License v1.0 |
| which accompanies this distribution, and is available at |
| http://www.eclipse.org/legal/cpl-v10.html |
| |
| Contributors: |
| IBM Corporation - Initial implementation |
| **********************************************************************/ |
| package org.eclipse.ant.internal.ui.editor.text; |
| |
| import org.eclipse.jface.text.IDocument; |
| import org.eclipse.jface.text.IDocumentPartitioner; |
| import org.eclipse.jface.text.rules.DefaultPartitioner; |
| import org.eclipse.ui.editors.text.StorageDocumentProvider; |
| |
| /** |
| * @since 3.0 |
| */ |
| public class AntStorageDocumentProvider extends StorageDocumentProvider { |
| |
| /* |
| * @see org.eclipse.ui.editors.text.StorageDocumentProvider#setupDocument(java.lang.Object, |
| * org.eclipse.jface.text.IDocument) |
| */ |
| protected void setupDocument(Object element, IDocument document) { |
| if (document != null) { |
| IDocumentPartitioner partitioner = createDocumentPartitioner(); |
| document.setDocumentPartitioner(partitioner); |
| partitioner.connect(document); |
| } |
| } |
| |
| private IDocumentPartitioner createDocumentPartitioner() { |
| return new DefaultPartitioner( |
| new AntEditorPartitionScanner(), new String[]{ |
| AntEditorPartitionScanner.XML_TAG, |
| AntEditorPartitionScanner.XML_COMMENT}); |
| } |
| } |