1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text;
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.jface.text.IRegion;
16 import org.eclipse.jface.text.reconciler.DirtyRegion;
17 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
18 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
21 * A reconciling strategy consisting of a sequence of internal reconciling strategies.
22 * By default, all requests are passed on to the contained strategies.
26 public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
28 /** The list of internal reconciling strategies. */
29 private IReconcilingStrategy[] fStrategies;
32 * Creates a new, empty composite reconciling strategy.
34 public CompositeReconcilingStrategy() {
38 * Sets the reconciling strategies for this composite strategy.
40 * @param strategies the strategies to be set or <code>null</code>
42 public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
43 fStrategies= strategies;
47 * Returns the previously set stratgies or <code>null</code>.
49 * @return the contained strategies or <code>null</code>
51 public IReconcilingStrategy[] getReconcilingStrategies() {
56 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
58 public void setDocument(IDocument document) {
59 if (fStrategies == null)
62 for (int i= 0; i < fStrategies.length; i++)
63 fStrategies[i].setDocument(document);
67 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
69 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
70 if (fStrategies == null)
73 for (int i= 0; i < fStrategies.length; i++)
74 fStrategies[i].reconcile(dirtyRegion, subRegion);
78 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
80 public void reconcile(IRegion partition) {
81 if (fStrategies == null)
84 for (int i= 0; i < fStrategies.length; i++)
85 fStrategies[i].reconcile(partition);
89 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
91 public void setProgressMonitor(IProgressMonitor monitor) {
92 if (fStrategies == null)
95 for (int i=0; i < fStrategies.length; i++) {
96 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
97 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
98 extension.setProgressMonitor(monitor);
104 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
106 public void initialReconcile() {
107 if (fStrategies == null)
110 for (int i=0; i < fStrategies.length; i++) {
111 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
112 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
113 extension.initialReconcile();