Bug 43766 [reconciling] ResourceMarkerAnnotationModel listener taking a long time
Build: I20030925 I was investigating a situation where adding breakpoints to a large file was very slow. It can take up to a second to add a breakpoint to a file such as Workspace.java (2000 lines). Almost all of this time is in the resource change listener added by ResourceMarkerAnnotationModel. First, a minor issue: Instead of adding a resource change listener that traverses the entire delta, you can locate a given resource delta within the resource change delta very quickly using IResourceDelta.findMember(): public void resourceChanged(IResourceChangeEvent e) { IResourceDelta delta= e.getDelta(); if (delta != null) { IResourceDelta child = delta.findMember(fResource.getFullPath()); if (child != null) update(child.getMarkerDeltas()); } } However, this was only a small speed improvement. The main problem is that the entire compilation unit is reparsed every time a breakpoint is added. I have added a profiler trace of where the time is going for adding a single breakpoint.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/filebuffers/CompilationUnitDocumentProvider2.java
import org.eclipse.jface.text.source.IAnnotationModelListener;
import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.IAnnotationExtension;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IProblemRequestor;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitAnnotationModelEvent;
import org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider;
import org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation;
import org.eclipse.jdt.internal.ui.javaeditor.ISavePolicy;
import org.eclipse.jdt.internal.ui.javaeditor.JavaMarkerAnnotation;
import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor;
import org.eclipse.jdt.internal.ui.text.java.IProblemRequestorExtension;
public class CompilationUnitDocumentProvider2 extends TextFileDocumentProvider implements ICompilationUnitDocumentProvider {
		
		/**
		 * Bundle of all required informations to allow working copy management. 
		 */
		static protected class CompilationUnitInfo extends FileInfo {