KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > reconciler > IReconcileStep


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.text.reconciler;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14
15 import org.eclipse.jface.text.IRegion;
16 import org.eclipse.jface.text.reconciler.DirtyRegion;
17
18
19 /**
20  * A reconcile step is one of several steps of a
21  * {@linkplain org.eclipse.jface.text.reconciler.IReconcilingStrategy reconcile strategy}
22  * that consists of several steps. This relationship is not coded into an interface but
23  * should be used by clients who's reconcile strategy consists of several steps.
24  * <p>
25  * If a reconcile step has an {@linkplain org.eclipse.jface.text.reconciler.IReconcilableModel input model}
26  * it will compute the correct model for the next step in the chain and set the next steps
27  * input model before <code>reconcile</code> gets called on that next step. After the last
28  * step has reconciled the {@linkplain org.eclipse.jface.text.reconciler.IReconcileResult reconcile result}
29  * array gets returned to the previous step. Each step in the chain adapts the result to its
30  * input model and returns it to its previous step.
31  * </p>
32  * <p>
33  * Example: Assume a strategy consists of steps A, B and C. And the main model is M.
34  * The strategy will set M to be A's input model. What will happen is:
35  * <ol>
36  * <li>A.setInputModel(M)</li>
37  * <li>A.reconcile: A reconciles M</li>
38  * <li>A computes the model for B =&gt; MB</li>
39  * <li>B.setInputModel(MB)</li>
40  * <li>B.reconcile: B reconciles MB</li>
41  * <li>B computes the model for C =&gt; MC</li>
42  * <li>C.setInputModel(MC)</li>
43  * <li>C.reconcile: C reconciles MC</li>
44  * <li>C returns result RC to step B</li>
45  * <li>B adapts the RC to MB and merges with its own results</li>
46  * <li>B returns result RB to step A</li>
47  * <li>A adapts the result to M and merges with its own results</li>
48  * <li>A returns the result to the reconcile strategy</li>
49  * </ol>
50  * </p>
51  * <p>
52  * This interface must be implemented by clients.
53  * </p>
54  * @since 3.0
55  */

56 public interface IReconcileStep {
57
58     /**
59      * Returns whether this is the last reconcile step or not.
60      *
61      * @return <code>true</code> iff this is the last reconcile step
62      */

63     boolean isLastStep();
64
65     /**
66      * Returns whether this is the first reconcile step or not.
67      *
68      * @return <code>true</code> iff this is the first reconcile step
69      */

70     boolean isFirstStep();
71
72     /**
73      * Sets the step which is in front of this step in the pipe.
74      * <p>
75      * Note: This method must be called at most once per reconcile step.
76      * </p>
77      *
78      * @param step the previous step
79      * @throws RuntimeException if called more than once
80      */

81     void setPreviousStep(IReconcileStep step);
82
83     /**
84      * Activates incremental reconciling of the specified dirty region.
85      * As a dirty region might span multiple content types, the segment of the
86      * dirty region which should be investigated is also provided to this
87      * reconciling strategy. The given regions refer to the document passed into
88      * the most recent call of {@link IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)}.
89      *
90      * @param dirtyRegion the document region which has been changed
91      * @param subRegion the sub region in the dirty region which should be reconciled
92      * @return an array with reconcile results
93      */

94     IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion);
95
96     /**
97      * Activates non-incremental reconciling. The reconciling strategy is just told
98      * that there are changes and that it should reconcile the given partition of the
99      * document most recently passed into {@link IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)}.
100      *
101      * @param partition the document partition to be reconciled
102      * @return an array with reconcile results
103      */

104     IReconcileResult[] reconcile(IRegion partition);
105
106     /**
107      * Sets the progress monitor for this reconcile step.
108      *
109      * @param monitor the progress monitor to be used
110      */

111     void setProgressMonitor(IProgressMonitor monitor);
112
113     /**
114      * Returns the progress monitor used to report progress.
115      *
116      * @return a progress monitor or <code>null</code> if no progress monitor is available
117      */

118     public IProgressMonitor getProgressMonitor();
119
120     /**
121      * Tells this reconcile step on which model it will
122      * work. This method will be called before any other method
123      * and can be called multiple times. The regions passed to the
124      * other methods always refer to the most recent model
125      * passed into this method.
126      *
127      * @param inputModel the model on which this step will work
128      */

129     void setInputModel(IReconcilableModel inputModel);
130 }
131
Popular Tags