Move dependencies check to later action performing stage
Originally, we checked dependencies at the very beginning, which impose
a performance issue on Android Studio.
Now, we move it to action performing stage to avoid the problem.
Test: N/A
Change-Id: I60032cd080236aa97174658abd46b0a790cc6908
diff --git a/src/com/google/appindexing/api/ApiCreator.java b/src/com/google/appindexing/api/ApiCreator.java
index 7fc83cb..36e2ec8 100644
--- a/src/com/google/appindexing/api/ApiCreator.java
+++ b/src/com/google/appindexing/api/ApiCreator.java
@@ -179,7 +179,7 @@
if (element == null) return false;
PsiClass activity = getSurroundingInheritingClass(element, SdkConstants.CLASS_ACTIVITY);
if (activity == null) return false;
- if (!hasEnoughDependencies(ModuleUtilCore.findModuleForPsiElement(element))) return false;
+
PsiCodeBlock onStart = getMethodBodyByName("onStart", SIGNATURE_ON_START, activity);
if (onStart == null) return true;
PsiCodeBlock onStop = getMethodBodyByName("onStop", SIGNATURE_ON_STOP, activity);
@@ -201,6 +201,10 @@
Logger.getInstance(ApiCreator.class).info("Unable to generate App Indexing API code.");
return;
}
+ if (!hasEnoughDependencies(myModule)) {
+ Logger.getInstance(ApiCreator.class).warn("Unable to generate App Indexing API code due to App Indexing API dependencies missing.");
+ return;
+ }
insertAppIndexingApiCodeInJavaFile(getDeepLinkOfActivity());
}