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

Commit

Permalink
Fix #60
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasKypta committed Jul 17, 2015
1 parent d980c72 commit e94a968
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>eu.inmite.android.plugin.butterknifezelezny</id>
<name>Android ButterKnife Zelezny</name>
<version>1.4-SNAPSHOT</version>
<version>1.3.2</version>
<vendor email="android@avast.com" url="http://github.com/avast">Avast</vendor>

<description><![CDATA[
Expand All @@ -11,8 +11,9 @@
<change-notes><![CDATA[
<html>
<b>1.4-SNAPSHOT</b>
<b>1.3.2</b> (7/17/2015)
<ul>
<li>Fixed plugin crash (#60)</li>
</ul>
<b>1.3.1</b> (7/16/2015)
Expand Down
3 changes: 3 additions & 0 deletions src/com/avast/android/butterknifezelezny/InjectAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ protected void showDialog(Project project, Editor editor, ArrayList<Element> ele
PsiClass clazz = getTargetClass(editor, file);

final IButterKnife butterKnife = ButterKnifeFactory.findButterKnifeForPsiElement(project, file);
if (butterKnife == null) {
return;
}

// get parent classes and check if it's an adapter
boolean createHolder = false;
Expand Down
7 changes: 6 additions & 1 deletion src/com/avast/android/butterknifezelezny/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.avast.android.butterknifezelezny.model.Element;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
Expand Down Expand Up @@ -311,7 +312,11 @@ public static boolean isEmptyString(String text) {
* @since 1.3
*/
public static boolean isClassAvailableForPsiFile(@NotNull Project project, @NotNull PsiElement psiElement, @NotNull String className) {
GlobalSearchScope moduleScope = ModuleUtil.findModuleForPsiElement(psiElement).getModuleWithDependenciesAndLibrariesScope(false);
Module module = ModuleUtil.findModuleForPsiElement(psiElement);
if (module == null) {
return false;
}
GlobalSearchScope moduleScope = module.getModuleWithDependenciesAndLibrariesScope(false);
PsiClass classInModule = JavaPsiFacade.getInstance(project).findClass(className, moduleScope);
return classInModule != null;
}
Expand Down

0 comments on commit e94a968

Please sign in to comment.