1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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 net.sourceforge.phpdt.internal.ui.text.java.IProblemRequestorExtension;
14 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
15 import net.sourceforge.phpdt.internal.ui.text.spelling.SpellReconcileStrategy;
16 import net.sourceforge.phpdt.ui.PreferenceConstants;
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
19 import org.eclipse.jface.text.IRegion;
20 import org.eclipse.jface.text.reconciler.DirtyRegion;
21 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
22 import org.eclipse.jface.text.source.IAnnotationModel;
23 import org.eclipse.ui.texteditor.IDocumentProvider;
24 import org.eclipse.ui.texteditor.ITextEditor;
27 * Reconciling strategy for Java code. This is a composite strategy containing the
28 * regular java model reconciler and the comment spell checking strategy.
32 public class JavaCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
34 private ITextEditor fEditor;
35 private JavaReconcilingStrategy fJavaStrategy;
38 * Creates a new Java reconciling strategy.
40 * @param editor the editor of the strategy's reconciler
41 * @param documentPartitioning the document partitioning this strategy uses for configuration
43 public JavaCompositeReconcilingStrategy(ITextEditor editor, String documentPartitioning) {
45 fJavaStrategy= new JavaReconcilingStrategy(editor);
46 setReconcilingStrategies(new IReconcilingStrategy[] {
48 new SpellReconcileStrategy(editor, documentPartitioning, PreferenceConstants.getPreferenceStore())
53 * Returns the problem requestor for the editor's input element.
55 * @return the problem requestor for the editor's input element
57 private IProblemRequestorExtension getProblemRequestorExtension() {
58 IDocumentProvider p= fEditor.getDocumentProvider();
60 // work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=51522
61 p= PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider();
63 IAnnotationModel m= p.getAnnotationModel(fEditor.getEditorInput());
64 if (m instanceof IProblemRequestorExtension)
65 return (IProblemRequestorExtension) m;
70 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
72 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
73 IProblemRequestorExtension e= getProblemRequestorExtension();
76 e.beginReportingSequence();
77 super.reconcile(dirtyRegion, subRegion);
79 e.endReportingSequence();
82 super.reconcile(dirtyRegion, subRegion);
87 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
89 public void reconcile(IRegion partition) {
90 IProblemRequestorExtension e= getProblemRequestorExtension();
93 e.beginReportingSequence();
94 super.reconcile(partition);
96 e.endReportingSequence();
99 super.reconcile(partition);
104 * Tells this strategy whether to inform its listeners.
106 * @param notify <code>true</code> if listeners should be notified
108 public void notifyListeners(boolean notify) {
109 fJavaStrategy.notifyListeners(notify);
113 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
115 public void initialReconcile() {
116 IProblemRequestorExtension e= getProblemRequestorExtension();
119 e.beginReportingSequence();
120 super.initialReconcile();
122 e.endReportingSequence();
125 super.initialReconcile();
130 * Called before reconciling is started.
134 public void aboutToBeReconciled() {
135 fJavaStrategy.aboutToBeReconciled();