1 11 package org.eclipse.jdt.internal.ui.text; 12 13 import org.eclipse.jface.text.IRegion; 14 import org.eclipse.jface.text.reconciler.DirtyRegion; 15 import org.eclipse.jface.text.reconciler.IReconcilingStrategy; 16 import org.eclipse.jface.text.source.IAnnotationModel; 17 import org.eclipse.jface.text.source.ISourceViewer; 18 19 import org.eclipse.ui.texteditor.IDocumentProvider; 20 import org.eclipse.ui.texteditor.ITextEditor; 21 22 import org.eclipse.jdt.internal.ui.JavaPlugin; 23 import org.eclipse.jdt.internal.ui.text.java.IProblemRequestorExtension; 24 import org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy; 25 import org.eclipse.jdt.internal.ui.text.spelling.JavaSpellingReconcileStrategy; 26 27 33 public class JavaCompositeReconcilingStrategy extends CompositeReconcilingStrategy { 34 35 private ITextEditor fEditor; 36 private JavaReconcilingStrategy fJavaStrategy; 37 38 45 public JavaCompositeReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) { 46 fEditor= editor; 47 fJavaStrategy= new JavaReconcilingStrategy(editor); 48 setReconcilingStrategies(new IReconcilingStrategy[] { 49 fJavaStrategy, 50 new JavaSpellingReconcileStrategy(viewer, editor) 51 }); 52 } 53 54 59 private IProblemRequestorExtension getProblemRequestorExtension() { 60 IDocumentProvider p= fEditor.getDocumentProvider(); 61 if (p == null) { 62 p= JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); 64 } 65 IAnnotationModel m= p.getAnnotationModel(fEditor.getEditorInput()); 66 if (m instanceof IProblemRequestorExtension) 67 return (IProblemRequestorExtension) m; 68 return null; 69 } 70 71 74 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { 75 IProblemRequestorExtension e= getProblemRequestorExtension(); 76 if (e != null) { 77 try { 78 e.beginReportingSequence(); 79 super.reconcile(dirtyRegion, subRegion); 80 } finally { 81 e.endReportingSequence(); 82 } 83 } else { 84 super.reconcile(dirtyRegion, subRegion); 85 } 86 } 87 88 91 public void reconcile(IRegion partition) { 92 IProblemRequestorExtension e= getProblemRequestorExtension(); 93 if (e != null) { 94 try { 95 e.beginReportingSequence(); 96 super.reconcile(partition); 97 } finally { 98 e.endReportingSequence(); 99 } 100 } else { 101 super.reconcile(partition); 102 } 103 } 104 105 110 public void notifyListeners(boolean notify) { 111 fJavaStrategy.notifyListeners(notify); 112 } 113 114 117 public void initialReconcile() { 118 IProblemRequestorExtension e= getProblemRequestorExtension(); 119 if (e != null) { 120 try { 121 e.beginReportingSequence(); 122 super.initialReconcile(); 123 } finally { 124 e.endReportingSequence(); 125 } 126 } else { 127 super.initialReconcile(); 128 } 129 } 130 131 136 public void aboutToBeReconciled() { 137 fJavaStrategy.aboutToBeReconciled(); 138 139 } 140 } 141 | Popular Tags |