Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Fix broken provides references when attempting to search for injectio…
Browse files Browse the repository at this point in the history
…n sources on a constructor annotated with @Inject.

Details:
- PsiConsultantImpl.getReturnClassFromMethod returns null when the method is a constructor. This patch fixes this function to return the containing class associated with the constructor.
  • Loading branch information
rjuang committed Nov 22, 2016
1 parent fd6864f commit aa29ca7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/com/squareup/ideaplugin/dagger/PsiConsultantImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiJavaCodeReferenceElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiModifierListOwner;
Expand Down Expand Up @@ -107,6 +108,10 @@ public static PsiClass getClass(PsiType psiType) {
}

public static PsiClass getReturnClassFromMethod(PsiMethod psiMethod) {
if (psiMethod.isConstructor()) {
return psiMethod.getContainingClass();
}

PsiClassType returnType = ((PsiClassType) psiMethod.getReturnType());
if (returnType != null) {
return returnType.resolve();
Expand Down

0 comments on commit aa29ca7

Please sign in to comment.