Source:
<code>public void setActiveEditor(IAction action, IEditorPart targetEditor) { <START> if (targetEditor != null) { <END> try { boolean auto = SourceLookupActivator.getDefault().isAutoAddSourceAttachment(); if (!auto) { return; } IClassFileEditorInput input = (IClassFileEditorInput) targetEditor.getEditorInput(); IJavaElement element = input.getClassFile(); while (element.getParent() != null) { element = element.getParent(); if (element instanceof IPackageFragmentRoot) { final IPackageFragmentRoot fragment = (IPackageFragmentRoot) element; IPath attachmentPath = fragment.getSourceAttachmentPath(); if (attachmentPath != null && !attachmentPath.isEmpty() && attachmentPath.toFile().exists()) { break; } if (fragment.isArchive()) { IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(fragment.getPath()); File file = iFile == null || iFile.getLocation() == null ? fragment.getPath().toFile() : iFile.getLocation().toFile(); IFileIdentificationManager identificationManager = new FileIdentificationManager(); final ArtifactKey artifact = identificationManager.identify(file, new NullProgressMonitor()); if (artifact != null) { IPath sourcePath = JBossSourceContainer.getSourcePath(artifact); if (sourcePath == null || !sourcePath.toFile().exists()) { Job job = JBossSourceContainer.downloadArtifact(file, artifact); job.addJobChangeListener(new IJobChangeListener() { @Override public void sleeping(IJobChangeEvent event) { } @Override public void scheduled(IJobChangeEvent event) { } @Override public void running(IJobChangeEvent event) { } @Override public void done(IJobChangeEvent event) { IPath sourcePath = JBossSourceContainer.getSourcePath(artifact); if (sourcePath != null && sourcePath.toFile().exists()) { SourceLookupUIActivator.attachSource(fragment, sourcePath); } } @Override public void awake(IJobChangeEvent event) { } @Override public void aboutToRun(IJobChangeEvent event) { } }); job.schedule(); } else { SourceLookupUIActivator.attachSource(fragment, sourcePath); } } } } } } catch (Exception e) { SourceLookupUIActivator.log(e); } } }</code><technical_language>this class method zero docs mentioning is wired in. "magic" nice</technical_language>

Target:
public void setActiveEditor(IAction action, IEditorPart targetEditor) { if (targetEditor != null) { try { String value = SourceLookupActivator.getDefault().getAutoAddSourceAttachment(); if (SourceLookupActivator.AUTO_ADD_JBOSS_SOURCE_ATTACHMENT_NEVER.equals(value)) { return; } IClassFileEditorInput input = (IClassFileEditorInput) targetEditor.getEditorInput(); IJavaElement element = input.getClassFile(); while (element.getParent() != null) { element = element.getParent(); if (element instanceof IPackageFragmentRoot) { final IPackageFragmentRoot fragment = (IPackageFragmentRoot) element; IPath attachmentPath = fragment.getSourceAttachmentPath(); if (attachmentPath != null && !attachmentPath.isEmpty() && attachmentPath.toFile().exists()) { break; } if (fragment.isArchive()) { IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(fragment.getPath()); File file = iFile == null || iFile.getLocation() == null ? fragment.getPath().toFile() : iFile.getLocation().toFile(); IFileIdentificationManager identificationManager = new FileIdentificationManager(); final ArtifactKey artifact = identificationManager.identify(file, new NullProgressMonitor()); if (artifact != null) { IPath sourcePath = JBossSourceContainer.getSourcePath(artifact); if (sourcePath == null || !sourcePath.toFile().exists()) { Job job = JBossSourceContainer.downloadArtifact(file, artifact); job.addJobChangeListener(new IJobChangeListener() { @Override public void sleeping(IJobChangeEvent event) { } @Override public void scheduled(IJobChangeEvent event) { } @Override public void running(IJobChangeEvent event) { } @Override public void done(IJobChangeEvent event) { IPath sourcePath = JBossSourceContainer.getSourcePath(artifact); if (sourcePath != null && sourcePath.toFile().exists()) { SourceLookupUtil.attachSource(fragment, sourcePath); } } @Override public void awake(IJobChangeEvent event) { } @Override public void aboutToRun(IJobChangeEvent event) { } }); job.schedule(); } else { SourceLookupUtil.attachSource(fragment, sourcePath); } } } } } } catch (Exception e) { SourceLookupUIActivator.log(e); } } }