Skip to content
This repository was archived by the owner on Aug 8, 2022. It is now read-only.

Commit 8ad705e

Browse files
authored
Merge pull request #240 from Shopify/224-bumblebee
Intellij plugin now supports Android Studio Bumblebee | 2021.1.1 Canary 9 | Build 211.*
2 parents 952b07b + 9f0c1c5 commit 8ad705e

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

Plugins/IntelliJ/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## [Unreleased]
44

5+
## [0.1.2]
6+
7+
### Updated
8+
9+
- Intellij plugin now supports Android Studio Bumblebee | 2021.1.1 Canary 9
10+
Build 211.*
11+
512
## [0.1.1]
613

714
### Updated

Plugins/IntelliJ/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
pluginGroup = com.shopify.testify
55
pluginName = Android Testify - Screenshot Instrumentation Tests
6-
pluginVersion = 0.1.1
6+
pluginVersion = 0.1.2
77
pluginSinceBuild = 193
8-
pluginUntilBuild = 203.*
8+
pluginUntilBuild = 211.*
99

1010
platformType = IC
1111
platformVersion = 2020.1

Plugins/IntelliJ/src/main/kotlin/com/shopify/testify/extensions/ScreenshotClassNavHandler.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
package com.shopify.testify.extensions
2525

2626
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
27+
import com.intellij.ide.DataManager
2728
import com.intellij.openapi.actionSystem.DefaultActionGroup
28-
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
2929
import com.intellij.openapi.editor.Editor
3030
import com.intellij.openapi.fileEditor.FileEditorManager
31-
import com.intellij.openapi.project.Project
3231
import com.intellij.openapi.ui.popup.JBPopup
3332
import com.intellij.openapi.ui.popup.JBPopupFactory
3433
import com.intellij.openapi.vfs.VirtualFile
@@ -41,11 +40,14 @@ import com.shopify.testify.actions.screenshot.ScreenshotClearAction
4140
import com.shopify.testify.actions.screenshot.ScreenshotPullAction
4241
import com.shopify.testify.actions.screenshot.ScreenshotRecordAction
4342
import com.shopify.testify.actions.screenshot.ScreenshotTestAction
43+
import java.awt.event.ComponentEvent
4444
import java.awt.event.MouseEvent
4545

4646
class ScreenshotClassNavHandler(private val anchorElement: PsiElement) : GutterIconNavigationHandler<PsiElement> {
4747

4848
override fun navigate(e: MouseEvent?, nameIdentifier: PsiElement) {
49+
if (e == null) return
50+
4951
val listOwner = nameIdentifier.parent
5052
val containingFile = listOwner.containingFile
5153
val virtualFile: VirtualFile? = PsiUtilCore.getVirtualFile(listOwner)
@@ -56,26 +58,26 @@ class ScreenshotClassNavHandler(private val anchorElement: PsiElement) : GutterI
5658
editor.caretModel.moveToOffset(nameIdentifier.textOffset)
5759
val file: PsiFile? = PsiDocumentManager.getInstance(project).getPsiFile(editor.document)
5860
if (file != null && virtualFile == file.virtualFile) {
59-
val popup: JBPopup? = createActionGroupPopup(anchorElement, project)
60-
popup?.show(RelativePoint(e!!))
61+
val popup: JBPopup = createActionGroupPopup(e, anchorElement)
62+
popup.show(RelativePoint(e))
6163
}
6264
}
6365
}
6466
}
6567

66-
private fun createActionGroupPopup(anchorElement: PsiElement, project: Project): JBPopup? {
68+
private fun createActionGroupPopup(event: ComponentEvent, anchorElement: PsiElement): JBPopup {
6769

6870
val group = DefaultActionGroup(
6971
ScreenshotTestAction(anchorElement),
7072
ScreenshotRecordAction(anchorElement),
7173
ScreenshotPullAction(anchorElement),
7274
ScreenshotClearAction(anchorElement)
7375
)
74-
76+
val dataContext = DataManager.getInstance().getDataContext(event.component)
7577
return JBPopupFactory.getInstance().createActionGroupPopup(
7678
"",
7779
group,
78-
SimpleDataContext.getProjectContext(project),
80+
dataContext,
7981
true,
8082
null,
8183
group.childrenCount

Plugins/IntelliJ/src/main/kotlin/com/shopify/testify/extensions/ScreenshotInstrumentationAnnotationNavHandler.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
package com.shopify.testify.extensions
2525

2626
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
27+
import com.intellij.ide.DataManager
2728
import com.intellij.openapi.actionSystem.DefaultActionGroup
28-
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
2929
import com.intellij.openapi.editor.Editor
3030
import com.intellij.openapi.fileEditor.FileEditorManager
31-
import com.intellij.openapi.project.Project
3231
import com.intellij.openapi.ui.popup.JBPopup
3332
import com.intellij.openapi.ui.popup.JBPopupFactory
3433
import com.intellij.openapi.vfs.VirtualFile
@@ -43,12 +42,15 @@ import com.shopify.testify.actions.screenshot.ScreenshotRecordAction
4342
import com.shopify.testify.actions.screenshot.ScreenshotTestAction
4443
import com.shopify.testify.actions.utility.DeleteBaselineAction
4544
import com.shopify.testify.actions.utility.RevealBaselineAction
45+
import java.awt.event.ComponentEvent
4646
import java.awt.event.MouseEvent
4747

4848
class ScreenshotInstrumentationAnnotationNavHandler(private val anchorElement: PsiElement) :
4949
GutterIconNavigationHandler<PsiElement> {
5050

5151
override fun navigate(e: MouseEvent?, nameIdentifier: PsiElement) {
52+
if (e == null) return
53+
5254
val listOwner = nameIdentifier.parent
5355
val containingFile = listOwner.containingFile
5456
val virtualFile: VirtualFile? = PsiUtilCore.getVirtualFile(listOwner)
@@ -59,14 +61,14 @@ class ScreenshotInstrumentationAnnotationNavHandler(private val anchorElement: P
5961
editor.caretModel.moveToOffset(nameIdentifier.textOffset)
6062
val file: PsiFile? = PsiDocumentManager.getInstance(project).getPsiFile(editor.document)
6163
if (file != null && virtualFile == file.virtualFile) {
62-
val popup: JBPopup? = createActionGroupPopup(anchorElement, project)
63-
popup?.show(RelativePoint(e!!))
64+
val popup: JBPopup = createActionGroupPopup(e, anchorElement)
65+
popup.show(RelativePoint(e))
6466
}
6567
}
6668
}
6769
}
6870

69-
private fun createActionGroupPopup(anchorElement: PsiElement, project: Project): JBPopup? {
71+
private fun createActionGroupPopup(event: ComponentEvent, anchorElement: PsiElement): JBPopup {
7072

7173
val group = DefaultActionGroup(
7274
ScreenshotTestAction(anchorElement),
@@ -76,11 +78,11 @@ class ScreenshotInstrumentationAnnotationNavHandler(private val anchorElement: P
7678
RevealBaselineAction(anchorElement),
7779
DeleteBaselineAction(anchorElement)
7880
)
79-
81+
val dataContext = DataManager.getInstance().getDataContext(event.component)
8082
return JBPopupFactory.getInstance().createActionGroupPopup(
8183
"",
8284
group,
83-
SimpleDataContext.getProjectContext(project),
85+
dataContext,
8486
true,
8587
null,
8688
group.childrenCount

0 commit comments

Comments
 (0)