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;
15 import org.eclipse.jface.text.IDocument;
16 import org.eclipse.jface.text.IRegion;
17 import org.eclipse.jface.text.reconciler.DirtyRegion;
18 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
19 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
22 * A reconciling strategy consisting of a sequence of internal reconciling strategies.
23 * By default, all requests are passed on to the contained strategies.
27 public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
29 /** The list of internal reconciling strategies. */
30 private IReconcilingStrategy[] fStrategies;
33 * Creates a new, empty composite reconciling strategy.
35 public CompositeReconcilingStrategy() {
39 * Sets the reconciling strategies for this composite strategy.
41 * @param strategies the strategies to be set or <code>null</code>
43 public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
44 fStrategies= strategies;
48 * Returns the previously set stratgies or <code>null</code>.
50 * @return the contained strategies or <code>null</code>
52 public IReconcilingStrategy[] getReconcilingStrategies() {
57 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
59 public void setDocument(IDocument document) {
60 if (fStrategies == null)
63 for (int i= 0; i < fStrategies.length; i++)
64 fStrategies[i].setDocument(document);
68 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
70 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
71 if (fStrategies == null)
74 for (int i= 0; i < fStrategies.length; i++)
75 fStrategies[i].reconcile(dirtyRegion, subRegion);
79 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
81 public void reconcile(IRegion partition) {
82 if (fStrategies == null)
85 for (int i= 0; i < fStrategies.length; i++)
86 fStrategies[i].reconcile(partition);
90 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
92 public void setProgressMonitor(IProgressMonitor monitor) {
93 if (fStrategies == null)
96 for (int i=0; i < fStrategies.length; i++) {
97 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
98 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
99 extension.setProgressMonitor(monitor);
105 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
107 public void initialReconcile() {
108 if (fStrategies == null)
111 for (int i=0; i < fStrategies.length; i++) {
112 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
113 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
114 extension.initialReconcile();