| /*=============================================================================# |
| # Copyright (c) 2012, 2019 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.redocs.tex.r.core.source; |
| |
| import java.util.List; |
| |
| import org.eclipse.jface.text.BadLocationException; |
| import org.eclipse.jface.text.IDocument; |
| import org.eclipse.jface.text.IRegion; |
| |
| import org.eclipse.statet.jcommons.collections.ImCollections; |
| |
| import org.eclipse.statet.ecommons.text.core.sections.AbstractDocContentSections; |
| import org.eclipse.statet.ecommons.text.core.treepartitioner.ITreePartitionNode; |
| |
| import org.eclipse.statet.docmlet.tex.core.source.ITexDocumentConstants; |
| import org.eclipse.statet.r.core.source.IRDocumentConstants; |
| import org.eclipse.statet.redocs.r.core.source.IDocContentSectionsRweaveExtension; |
| import org.eclipse.statet.redocs.r.core.source.RweaveDocSectionTreePartImpl; |
| |
| |
| public class LtxRweaveDocumentContentInfo extends AbstractDocContentSections |
| implements IDocContentSectionsRweaveExtension { |
| |
| |
| public static final String LTX= ITexDocumentConstants.LTX_PARTITIONING; |
| public static final String R_CHUNK_CONTROL= "org.eclipse.statet.LtxR-ChunkControl"; //$NON-NLS-1$ |
| public static final String R= IRDocumentConstants.R_PARTITIONING; |
| |
| |
| public static final IDocContentSectionsRweaveExtension INSTANCE= new LtxRweaveDocumentContentInfo(); |
| |
| |
| private final RweaveDocSectionTreePartImpl rweaveImpl; |
| |
| |
| public LtxRweaveDocumentContentInfo() { |
| super(ITexRweaveDocumentConstants.LTX_R_PARTITIONING, LTX, |
| ImCollections.newList(LTX, R_CHUNK_CONTROL, R) ); |
| |
| this.rweaveImpl= new RweaveDocSectionTreePartImpl(this); |
| } |
| |
| |
| @Override |
| public final String getTypeByPartition(final String contentType) { |
| if (IRDocumentConstants.R_ANY_CONTENT_CONSTRAINT.matches(contentType)) { |
| return R; |
| } |
| if (ITexRweaveDocumentConstants.RCHUNK_PARTITION_CONSTRAINT.matches(contentType)) { |
| return R_CHUNK_CONTROL; |
| } |
| return LTX; |
| } |
| |
| |
| @Override |
| public ITreePartitionNode getRChunkRegion(final IDocument document, final int offset) |
| throws BadLocationException { |
| return this.rweaveImpl.getRChunkRegion(document, offset); |
| } |
| |
| @Override |
| public List<ITreePartitionNode> getRChunkRegions(final IDocument document, |
| final int offset, final int length) |
| throws BadLocationException { |
| return this.rweaveImpl.getRChunkCodeRegions(document, offset, length); |
| } |
| |
| @Override |
| public IRegion getRChunkContentRegion(final IDocument document, final int offset) |
| throws BadLocationException { |
| return this.rweaveImpl.getRChunkContentRegion(document, offset); |
| } |
| |
| @Override |
| public ITreePartitionNode getRCodeRegion(final IDocument document, final int offset) |
| throws BadLocationException { |
| return this.rweaveImpl.getRCodeRegion(document, offset); |
| } |
| |
| @Override |
| public List<ITreePartitionNode> getRChunkCodeRegions(final IDocument document, |
| final int offset, final int length) |
| throws BadLocationException { |
| return this.rweaveImpl.getRChunkCodeRegions(document, offset, length); |
| } |
| |
| } |