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.ui.WebUI;
18 //import net.sourceforge.phpeclipse.PHPeclipsePlugin;
20 import org.eclipse.jface.text.IRegion;
21 import org.eclipse.jface.text.reconciler.DirtyRegion;
22 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
23 import org.eclipse.jface.text.source.IAnnotationModel;
24 import org.eclipse.ui.texteditor.IDocumentProvider;
25 import org.eclipse.ui.texteditor.ITextEditor;
28 * Reconciling strategy for Java code. This is a composite strategy containing
29 * the regular java model reconciler and the comment spell checking strategy.
33 public class JavaCompositeReconcilingStrategy extends
34 CompositeReconcilingStrategy {
36 private ITextEditor fEditor;
38 private JavaReconcilingStrategy fJavaStrategy;
41 * Creates a new Java reconciling strategy.
44 * the editor of the strategy's reconciler
45 * @param documentPartitioning
46 * the document partitioning this strategy uses for configuration
48 public JavaCompositeReconcilingStrategy(ITextEditor editor,
49 String documentPartitioning) {
51 fJavaStrategy = new JavaReconcilingStrategy(editor);
52 setReconcilingStrategies(new IReconcilingStrategy[] {
54 new SpellReconcileStrategy(editor, documentPartitioning,
55 PreferenceConstants.getPreferenceStore()) });
59 * Returns the problem requestor for the editor's input element.
61 * @return the problem requestor for the editor's input element
63 private IProblemRequestorExtension getProblemRequestorExtension() {
64 IDocumentProvider p = fEditor.getDocumentProvider();
68 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=51522
69 p = WebUI.getDefault()
70 .getCompilationUnitDocumentProvider();
71 } catch (NullPointerException npe) {
75 IAnnotationModel m = p.getAnnotationModel(fEditor.getEditorInput());
76 if (m instanceof IProblemRequestorExtension)
77 return (IProblemRequestorExtension) m;
82 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,
83 * org.eclipse.jface.text.IRegion)
85 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
86 IProblemRequestorExtension e = getProblemRequestorExtension();
89 e.beginReportingSequence();
90 super.reconcile(dirtyRegion, subRegion);
92 e.endReportingSequence();
95 super.reconcile(dirtyRegion, subRegion);
100 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
102 public void reconcile(IRegion partition) {
103 IProblemRequestorExtension e = getProblemRequestorExtension();
106 e.beginReportingSequence();
107 super.reconcile(partition);
109 e.endReportingSequence();
112 super.reconcile(partition);
117 * Tells this strategy whether to inform its listeners.
120 * <code>true</code> if listeners should be notified
122 public void notifyListeners(boolean notify) {
123 fJavaStrategy.notifyListeners(notify);
127 * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
129 public void initialReconcile() {
130 IProblemRequestorExtension e = getProblemRequestorExtension();
133 e.beginReportingSequence();
134 super.initialReconcile();
136 e.endReportingSequence();
139 super.initialReconcile();
144 * Called before reconciling is started.
148 public void aboutToBeReconciled() {
149 fJavaStrategy.aboutToBeReconciled();