Source:
private void registerListeners() { final IWorkbench workbench = PlatformUI.getWorkbench(); workbench.getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchWindow active = workbench.getActiveWorkbenchWindow(); final IWorkbenchPage page = active.getActivePage(); IPartListener2 partListener = new IPartListener2() { CodanCReconciler reconciler = new CodanCReconciler(); public void partActivated(IWorkbenchPartReference partRef) { } public void partDeactivated(IWorkbenchPartReference partRef) { } public void partOpened(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (part instanceof CEditor) { CEditor editor = (CEditor) part; reconciler.install(editor); processResource((IResource) editor.getEditorInput().getAdapter(IResource.class)); } } private void processResource(IResource resource) { CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder(); builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN); } public void partHidden(IWorkbenchPartReference partRef) { } public void partVisible(IWorkbenchPartReference partRef) { } public void partClosed(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (part instanceof CEditor) { reconciler.uninstall((CEditor) part); } } public void partBroughtToTop(IWorkbenchPartReference partRef) { } public void partInputChanged(IWorkbenchPartReference partRef) { } }; page.addPartListener(partListener); IEditorReference[] editorReferences = page.getEditorReferences(); for (int i = 0; i < editorReferences.length; i++) { IEditorReference ref = editorReferences[i]; partListener.partOpened(ref); } } }); }

Target:
private void registerListeners() { final IWorkbench workbench = PlatformUI.getWorkbench(); workbench.getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchWindow active = workbench.getActiveWorkbenchWindow(); final IWorkbenchPage page = active.getActivePage(); IPartListener2 partListener = new IPartListener2() { CodanCReconciler reconciler = new CodanCReconciler(); public void partActivated(IWorkbenchPartReference partRef) { } public void partDeactivated(IWorkbenchPartReference partRef) { } public void partOpened(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (part instanceof CEditor) { CEditor editor = (CEditor) part; reconciler.install(editor); IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); if (resource != null) { processResource(resource); } } } private void processResource(IResource resource) { CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder(); builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN); } public void partHidden(IWorkbenchPartReference partRef) { } public void partVisible(IWorkbenchPartReference partRef) { } public void partClosed(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (part instanceof CEditor) { reconciler.uninstall((CEditor) part); } } public void partBroughtToTop(IWorkbenchPartReference partRef) { } public void partInputChanged(IWorkbenchPartReference partRef) { } }; page.addPartListener(partListener); IEditorReference[] editorReferences = page.getEditorReferences(); for (int i = 0; i < editorReferences.length; i++) { IEditorReference ref = editorReferences[i]; partListener.partOpened(ref); } } }); }