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
22 * strategies. By default, all requests are passed on to the contained
27 public class CompositeReconcilingStrategy implements IReconcilingStrategy,
28 IReconcilingStrategyExtension {
30 /** The list of internal reconciling strategies. */
31 private IReconcilingStrategy[] fStrategies;
34 * Creates a new, empty composite reconciling strategy.
36 public CompositeReconcilingStrategy() {
40 * Sets the reconciling strategies for this composite strategy.
43 * the strategies to be set or <code>null</code>
45 public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
46 fStrategies = strategies;
50 * Returns the previously set stratgies or <code>null</code>.
52 * @return the contained strategies or <code>null</code>
54 public IReconcilingStrategy[] getReconcilingStrategies() {
59 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
61 public void setDocument(IDocument document) {
62 if (fStrategies == null)
65 for (int i = 0; i < fStrategies.length; i++)
66 fStrategies[i].setDocument(document);
70 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,
71 * org.eclipse.jface.text.IRegion)
73 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
74 if (fStrategies == null)
77 for (int i = 0; i < fStrategies.length; i++)
78 fStrategies[i].reconcile(dirtyRegion, subRegion);
82 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
84 public void reconcile(IRegion partition) {
85 if (fStrategies == null)
88 for (int i = 0; i < fStrategies.length; i++)
89 fStrategies[i].reconcile(partition);
93 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
95 public void setProgressMonitor(IProgressMonitor monitor) {
96 if (fStrategies == null)
99 for (int i = 0; i < fStrategies.length; i++) {
100 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
101 IReconcilingStrategyExtension extension = (IReconcilingStrategyExtension) fStrategies[i];
102 extension.setProgressMonitor(monitor);
108 * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
110 public void initialReconcile() {
111 if (fStrategies == null)
114 for (int i = 0; i < fStrategies.length; i++) {
115 if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
116 IReconcilingStrategyExtension extension = (IReconcilingStrategyExtension) fStrategies[i];
117 extension.initialReconcile();