From e39c7b0a16666bc768b849f46256efd8fd2f4801 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 11:20:56 +0000 Subject: [PATCH 1/4] Fix: Resolve IllegalArgumentException in AsciiDoc editor during builds Fixed scheduling rule conflicts that occurred when editing AsciiDoc files while Eclipse auto-build was running. The error manifested as: "IllegalArgumentException: Attempted to beginRule: MultiRule[], does not match outer scope rule: R/" Changes: - Replace IResource.exists() with isAccessible() to avoid acquiring locks - Add null checks before accessing parent containers - Add accessibility checks for image folders and include paths - Improve error handling in hover and hyperlink detectors Affected components: - IncludeHyperlinkDetector: Check parent accessibility before members() - ImageHyperlinkDetector: Validate parent and img folder accessibility - ImageHover: Use isAccessible() instead of exists() for image files - LinkHyperlinkDetector: Check file accessibility for internal links The isAccessible() method is a lighter-weight check that doesn't acquire workspace locks, preventing conflicts with the build manager's root scheduling rule. --- .../com/vogella/ide/editor/asciidoc/ImageHover.java | 13 ++++++++++--- .../ide/editor/asciidoc/ImageHyperlinkDetector.java | 7 +++++++ .../editor/asciidoc/IncludeHyperlinkDetector.java | 3 ++- .../ide/editor/asciidoc/LinkHyperlinkDetector.java | 5 +++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java index 89b6360..112f1eb 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java @@ -43,14 +43,21 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { IContainer parent = getParentFolder(); + if (parent == null || !parent.isAccessible()) { + return ""; + } + IContainer imgFolder = parent.getFolder(IPath.fromOSString("img")); + if (!imgFolder.isAccessible()) { + return "Image folder 'img' not found"; + } + - IFile imageFile = imgFolder.getFile(IPath.fromOSString(imageName)); // Replace "filename.ext" with your actual file name - // Check if image file exists - if (imageFile.exists()) { + // Check if image file exists - use isAccessible to avoid rule conflicts + if (imageFile.isAccessible()) { // Load and display the image in the hover (assuming HTML rendering is supported) return "\"""; } else { diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java index 83d9278..9148e68 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java @@ -46,7 +46,14 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo lineInformationOfOffset.getLength() - IMAGE_PROPERTY.length()); IContainer parent = getParentFolder(); + if (parent == null || !parent.isAccessible()) { + return null; + } + IContainer imgFolder = parent.getFolder(IPath.fromOSString("img")); + if (!imgFolder.isAccessible()) { + return null; + } // Only take resources, which have the "png" file extension IHyperlink[] result = Arrays.stream(imgFolder.members()) diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java index cff53ce..92462c3 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java @@ -72,7 +72,8 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo parent = subfolder; } - if (!parent.exists()) { + // Check if parent is accessible - avoid potential rule conflicts during builds + if (parent == null || !parent.isAccessible()) { return null; } diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java index b8b87bd..9cbb97c 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java @@ -74,9 +74,10 @@ public void open() { }; } else if (target.startsWith("./") || target.startsWith("../")) { // Internal file link → open in Eclipse editor - if (parent != null && parent.exists()) { + // Use isAccessible to avoid rule conflicts during builds + if (parent != null && parent.isAccessible()) { IResource resource = parent.findMember(new Path(target)); - if (resource instanceof IFile file) { + if (resource instanceof IFile file && file.isAccessible()) { return new IHyperlink[] { new ResourceHyperlink(targetRegion, resource.getName(), file) }; From 34a75eeaf3960ac66972a87ba628f6626579c5e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 11:51:40 +0000 Subject: [PATCH 2/4] Refactor: Replace hardcoded strings with constants in AsciiDoc image handlers Improved code maintainability by eliminating hardcoded "img" strings: - ImageHover: Use existing IMAGE_DIRECTORY constant for folder path and error message - ImageHyperlinkDetector: Add IMAGE_DIRECTORY constant and use it consistently This makes the code more maintainable and ensures consistency across both classes that handle image directory references. Addresses code review feedback from automated analysis. --- .../src/com/vogella/ide/editor/asciidoc/ImageHover.java | 4 ++-- .../vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java index 112f1eb..080f1d9 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java @@ -47,9 +47,9 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { return ""; } - IContainer imgFolder = parent.getFolder(IPath.fromOSString("img")); + IContainer imgFolder = parent.getFolder(IPath.fromOSString(IMAGE_DIRECTORY)); if (!imgFolder.isAccessible()) { - return "Image folder 'img' not found"; + return "Image folder '" + IMAGE_DIRECTORY + "' not found"; } diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java index 9148e68..458a507 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java @@ -25,6 +25,7 @@ public class ImageHyperlinkDetector extends AbstractHyperlinkDetector { private static final String IMAGE_PROPERTY = "image::"; + private static final String IMAGE_DIRECTORY = "img"; @Override public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { @@ -50,7 +51,7 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo return null; } - IContainer imgFolder = parent.getFolder(IPath.fromOSString("img")); + IContainer imgFolder = parent.getFolder(IPath.fromOSString(IMAGE_DIRECTORY)); if (!imgFolder.isAccessible()) { return null; } From 2c77214e043a2580f6ccd7b8df7484aa987b81c0 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 18 Nov 2025 11:12:12 +0100 Subject: [PATCH 3/4] Refactor: Address review feedback for PR 48 - Refactored the duplicated `getParentFolder()` method into a shared utility class `AsciiDocResourceUtil` to improve maintainability and prevent potential `NullPointerException`s. - Replaced hardcoded strings with constants from the new `AsciiDocConstants` class. - Updated `ImageHover`, `ImageHyperlinkDetector`, `IncludeHyperlinkDetector`, and `LinkHyperlinkDetector` to use the new utility class and constants. --- .../editor/asciidoc/AsciiDocConstants.java | 6 ++++ .../ide/editor/asciidoc/ImageHover.java | 33 ++++--------------- .../asciidoc/ImageHyperlinkDetector.java | 21 +++--------- .../asciidoc/IncludeHyperlinkDetector.java | 18 ++-------- .../asciidoc/LinkHyperlinkDetector.java | 17 ++-------- .../asciidoc/util/AsciiDocResourceUtil.java | 25 ++++++++++++++ 6 files changed, 47 insertions(+), 73 deletions(-) create mode 100644 com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/AsciiDocConstants.java create mode 100644 com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/AsciiDocConstants.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/AsciiDocConstants.java new file mode 100644 index 0000000..bf3585f --- /dev/null +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/AsciiDocConstants.java @@ -0,0 +1,6 @@ +package com.vogella.ide.editor.asciidoc; + +public class AsciiDocConstants { + public static final String IMAGESDIR = "imagesdir"; + public static final String IMG_DIRECTORY = "img"; +} diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java index 080f1d9..a60647f 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHover.java @@ -1,26 +1,22 @@ package com.vogella.ide.editor.asciidoc; +import java.io.File; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; -import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import java.io.File; +import com.vogella.ide.editor.asciidoc.util.AsciiDocResourceUtil; public class ImageHover implements ITextHover { private static final String IMAGE_PREFIX = "image::"; - private static final String IMAGE_DIRECTORY = "img"; // Directory for images @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { @@ -42,18 +38,18 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { String imageName = lineContent.substring(startIndex, endIndex).trim(); - IContainer parent = getParentFolder(); + IContainer parent = AsciiDocResourceUtil.getParentFolder(); if (parent == null || !parent.isAccessible()) { return ""; } - IContainer imgFolder = parent.getFolder(IPath.fromOSString(IMAGE_DIRECTORY)); + IContainer imgFolder = parent.getFolder(IPath.fromOSString(AsciiDocConstants.IMG_DIRECTORY)); if (!imgFolder.isAccessible()) { - return "Image folder '" + IMAGE_DIRECTORY + "' not found"; + return "Image folder '" + AsciiDocConstants.IMG_DIRECTORY + "' not found"; } - IFile imageFile = imgFolder.getFile(IPath.fromOSString(imageName)); // Replace "filename.ext" with your actual file name + IFile imageFile = imgFolder.getFile(IPath.fromOSString(imageName)); // Check if image file exists - use isAccessible to avoid rule conflicts @@ -80,19 +76,4 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { public IRegion getHoverRegion(ITextViewer textViewer, int offset) { return new Region(offset, 0); } - - - private IContainer getParentFolder() { - IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); - Object object = context.get("activeEditor"); - - if (object instanceof IEditorPart activeEditor) { - - IEditorInput editorInput = activeEditor.getEditorInput(); - IResource adapter = editorInput.getAdapter(IResource.class); - IContainer parent = adapter.getParent(); - return parent; - } - return null; - } } diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java index 458a507..ac82e24 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/ImageHyperlinkDetector.java @@ -22,10 +22,11 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import com.vogella.ide.editor.asciidoc.util.AsciiDocResourceUtil; + public class ImageHyperlinkDetector extends AbstractHyperlinkDetector { private static final String IMAGE_PROPERTY = "image::"; - private static final String IMAGE_DIRECTORY = "img"; @Override public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { @@ -46,12 +47,12 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo Region targetRegion = new Region(lineInformationOfOffset.getOffset() + IMAGE_PROPERTY.length(), lineInformationOfOffset.getLength() - IMAGE_PROPERTY.length()); - IContainer parent = getParentFolder(); + IContainer parent = AsciiDocResourceUtil.getParentFolder(); if (parent == null || !parent.isAccessible()) { return null; } - IContainer imgFolder = parent.getFolder(IPath.fromOSString(IMAGE_DIRECTORY)); + IContainer imgFolder = parent.getFolder(IPath.fromOSString(AsciiDocConstants.IMG_DIRECTORY)); if (!imgFolder.isAccessible()) { return null; } @@ -75,20 +76,6 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo return null; } - - private IContainer getParentFolder() { - IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); - Object object = context.get("activeEditor"); - - if (object instanceof IEditorPart activeEditor) { - - IEditorInput editorInput = activeEditor.getEditorInput(); - IResource adapter = editorInput.getAdapter(IResource.class); - IContainer parent = adapter.getParent(); - return parent; - } - return null; - } } diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java index 92462c3..640ffe6 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/IncludeHyperlinkDetector.java @@ -19,6 +19,8 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; +import com.vogella.ide.editor.asciidoc.util.AsciiDocResourceUtil; + public class IncludeHyperlinkDetector extends AbstractHyperlinkDetector { private static final String HYPERLINK_PROPERTY = "include::"; @@ -27,7 +29,7 @@ public class IncludeHyperlinkDetector extends AbstractHyperlinkDetector { public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { IDocument document = textViewer.getDocument(); - IContainer parent = getParentFolder(); + IContainer parent = AsciiDocResourceUtil.getParentFolder(); try { int offset = region.getOffset(); @@ -103,18 +105,4 @@ public static boolean containsSubfolder(String relativePath) { return lastIndexOfParent != -1 && normalizedPath.indexOf("/", lastIndexOfParent + 3) != -1; } - private IContainer getParentFolder() { - IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); - Object object = context.get("activeEditor"); - - if (object instanceof IEditorPart activeEditor) { - - IEditorInput editorInput = activeEditor.getEditorInput(); - IResource adapter = editorInput.getAdapter(IResource.class); - IContainer parent = adapter.getParent(); - return parent; - } - return null; - } - } \ No newline at end of file diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java index 9cbb97c..d58ef31 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/LinkHyperlinkDetector.java @@ -16,6 +16,7 @@ import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; import org.eclipse.jface.text.hyperlink.IHyperlink; import org.eclipse.swt.program.Program; +import com.vogella.ide.editor.asciidoc.util.AsciiDocResourceUtil; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; @@ -28,7 +29,7 @@ public class LinkHyperlinkDetector extends AbstractHyperlinkDetector { public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { IDocument document = textViewer.getDocument(); - IContainer parent = getParentFolder(); + IContainer parent = AsciiDocResourceUtil.getParentFolder(); try { int offset = region.getOffset(); @@ -91,18 +92,4 @@ public void open() { return null; } - - private IContainer getParentFolder() { - IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); - Object object = context.get("activeEditor"); - - if (object instanceof IEditorPart activeEditor) { - IEditorInput editorInput = activeEditor.getEditorInput(); - IResource adapter = editorInput.getAdapter(IResource.class); - if (adapter != null) { - return adapter.getParent(); - } - } - return null; - } } diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java new file mode 100644 index 0000000..62ba1e4 --- /dev/null +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java @@ -0,0 +1,25 @@ +package com.vogella.ide.editor.asciidoc.util; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +public class AsciiDocResourceUtil { + + public static IContainer getParentFolder() { + IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); + Object object = context.get("activeEditor"); + + if (object instanceof IEditorPart activeEditor) { + IEditorInput editorInput = activeEditor.getEditorInput(); + IResource adapter = editorInput.getAdapter(IResource.class); + if (adapter != null) { + return adapter.getParent(); + } + } + return null; + } +} From ecd788f97a2df068c95d31c888982caa891dfb6b Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 18 Nov 2025 11:55:55 +0100 Subject: [PATCH 4/4] Fixes: Address review feedback for PR 48 --- .../asciidoc/util/AsciiDocResourceUtil.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java index 62ba1e4..fb06eef 100644 --- a/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java +++ b/com.vogella.ide.editor.asciidoc/src/com/vogella/ide/editor/asciidoc/util/AsciiDocResourceUtil.java @@ -1,8 +1,11 @@ package com.vogella.ide.editor.asciidoc.util; +import java.util.concurrent.atomic.AtomicReference; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; @@ -10,16 +13,23 @@ public class AsciiDocResourceUtil { public static IContainer getParentFolder() { - IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); - Object object = context.get("activeEditor"); + // Use AtomicReference to hold the result from the UI thread + final AtomicReference containerRef = new AtomicReference<>(); + + // Ensure UI-related code runs on the UI thread + Display.getDefault().syncExec(() -> { + IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); + Object object = context.get("activeEditor"); - if (object instanceof IEditorPart activeEditor) { - IEditorInput editorInput = activeEditor.getEditorInput(); - IResource adapter = editorInput.getAdapter(IResource.class); - if (adapter != null) { - return adapter.getParent(); + if (object instanceof IEditorPart activeEditor) { + IEditorInput editorInput = activeEditor.getEditorInput(); + IResource adapter = editorInput.getAdapter(IResource.class); + if (adapter != null) { + containerRef.set(adapter.getParent()); + } } - } - return null; + }); + + return containerRef.get(); } }