Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Unified Diff: plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java

Issue 9704071: Issue 61: Provide an extension point to have custom local file -> script mapping (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: format Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java
diff --git a/plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java b/plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java
index 69803109284cbe944b67ec25ac02dbcc0dcf3459..d9043decd1b8ff2f29c6436ecb8ab399d2545276 100644
--- a/plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java
+++ b/plugins/org.chromium.debug.core/src/org/chromium/debug/core/ReverseSourceLookup.java
@@ -46,10 +46,10 @@ public class ReverseSourceLookup {
}
public static boolean isGoodTargetContainer(ISourceContainer container) {
- return wrapNonVirtualContainer(container) != null;
+ return wrapSourceContainer(container) != null;
}
- private VmResourceId tryForContainer(IFile sourceFile, ISourceContainer container)
+ private static VmResourceId tryForContainer(IFile sourceFile, ISourceContainer container)
throws CoreException {
if (container.isComposite() && isSupportedCompositeContainer(container)) {
ISourceContainer[] subContainers = container.getSourceContainers();
@@ -77,22 +77,29 @@ public class ReverseSourceLookup {
* However it doesn't make sense for all composite containers (some of them may return their
* subdirectories as containers, which is not what we need).
*/
- private boolean isSupportedCompositeContainer(ISourceContainer container) {
+ private static boolean isSupportedCompositeContainer(ISourceContainer container) {
return container instanceof DefaultSourceContainer;
}
/**
* @param container that may not wrap VProjectSourceContainer
*/
- private String tryForNonVirtualContainer(IFile resource, ISourceContainer container) {
- ContainerWrapper wrapper = wrapNonVirtualContainer(container);
+ private static String tryForNonVirtualContainer(IFile resource, ISourceContainer container) {
+ ContainerWrapper wrapper = wrapSourceContainer(container);
if (wrapper == null) {
return null;
}
return wrapper.lookup(resource);
}
- private static ContainerWrapper wrapNonVirtualContainer(ISourceContainer container) {
+ /**
+ * Possibly wraps container as {@link ContainerWrapper} interface.
+ * @param container any source container except virtual project container
+ * ({@link VProjectSourceContainer}), which must get more complex interface but shouldn't
+ * occur as an actual argument anyway
+ * @return container wrapper or null
+ */
+ public static ContainerWrapper wrapSourceContainer(ISourceContainer container) {
if (container instanceof ContainerSourceContainer) {
final ContainerSourceContainer containerSourceContainer =
(ContainerSourceContainer) container;
@@ -109,21 +116,17 @@ public class ReverseSourceLookup {
return lookupInResourceContainer(resource, ResourcesPlugin.getWorkspace().getRoot());
}
};
- } else if (container instanceof SourceNameMapperContainer) {
- SourceNameMapperContainer mappingContainer = (SourceNameMapperContainer) container;
- final ContainerWrapper targetContainerWrapper =
- wrapNonVirtualContainer(mappingContainer.getTargetContainer());
- final String prefix = mappingContainer.getPrefix();
- return new ContainerWrapper() {
- @Override
- public String lookup(IFile resource) {
- String subResult = targetContainerWrapper.lookup(resource);
- if (subResult == null) {
- return null;
- }
- return prefix + subResult;
+ } else {
+ ReverseLookupContainer reverseLookupContainer =
+ ReverseLookupContainer.Cast.fromContainer(container);
+ if (reverseLookupContainer != null) {
+ ContainerWrapper containerWrapper = reverseLookupContainer.getReveseLookupImpl();
+ if (containerWrapper != null) {
+ return containerWrapper;
}
- };
+ // Fall through.
+ }
+ // Fall through.
}
return null;
@@ -133,7 +136,7 @@ public class ReverseSourceLookup {
* Wraps a container. This interface guarantees that original container with all inner containers
* are supported by our reversed lookup.
*/
- private interface ContainerWrapper {
+ public interface ContainerWrapper {
String lookup(IFile resource);
}

Powered by Google App Engine
This is Rietveld 408576698