Skip to content

Commit

Permalink
Merge pull request #60 from pszklarska/go-to-pub-dev
Browse files Browse the repository at this point in the history
Add option to go to the package on pub.dev
  • Loading branch information
pszklarska authored May 7, 2022
2 parents 51b598c + 60c8142 commit 86a1628
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

## [Unreleased]
### Added
- Support for preview and prerelease plugins ([#38](https://github.com/pszklarska/FlutterPubVersionChecker/issues/38))
- Support for preview and prerelease packages ([#38](https://github.com/pszklarska/FlutterPubVersionChecker/issues/38))
- Go to pub.dev from the quick-fix menu ([#54](https://github.com/pszklarska/FlutterPubVersionChecker/issues/54))
### Fixed
- Errors not being reported to crash tracker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.openapi.application.runReadAction
import com.intellij.psi.PsiFile
import pl.pszklarska.pubversionchecker.dto.DependencyDescription
import pl.pszklarska.pubversionchecker.parsing.YamlParser
import pl.pszklarska.pubversionchecker.quickfix.GoToPubDevQuickFix
import pl.pszklarska.pubversionchecker.quickfix.UpdateAllDependenciesQuickFix
import pl.pszklarska.pubversionchecker.quickfix.UpdateDependencyQuickFix
import pl.pszklarska.pubversionchecker.resources.Strings
Expand Down Expand Up @@ -44,6 +45,8 @@ class PubPackagesAnnotator : ExternalAnnotator<PubPackagesAnnotator.Info, PubPac
.registerFix()
.newFix(UpdateAllDependenciesQuickFix(annotationResult.annotations))
.registerFix()
.newFix(GoToPubDevQuickFix(it.dependency.packageName))
.registerFix()
.create()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package pl.pszklarska.pubversionchecker.quickfix

import com.intellij.codeInsight.intention.impl.BaseIntentionAction
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import com.intellij.util.IncorrectOperationException
import pl.pszklarska.pubversionchecker.resources.Strings


private const val PUB_DEV_PACKAGES_URL = "https://pub.dev/packages/"

internal class GoToPubDevQuickFix(
private val packageName: String
) : BaseIntentionAction() {

override fun getText(): String {
return Strings.goToPubDevFixDescription.format(packageName)
}

override fun getFamilyName(): String {
return Strings.fixFamilyName
}

override fun isAvailable(project: Project, editor: Editor, file: PsiFile): Boolean {
return true
}

@Throws(IncorrectOperationException::class)
override fun invoke(project: Project, editor: Editor, file: PsiFile) {
BrowserUtil.browse(PUB_DEV_PACKAGES_URL + packageName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class UpdateDependencyQuickFix(
) : BaseIntentionAction() {

override fun getText(): String {
return "${Strings.updateDescription} $packageName"
return Strings.updateFixDescription.format(packageName)
}

override fun getFamilyName(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ class Strings {

companion object {
const val annotationDescription = "Latest available version is:"
const val updateDescription = "Update"
const val updateFixDescription = "Update %s"
const val updateAllFixDescription =
"Update\u200B all" // zero-length whitespace to place "Update all" below other fixes
const val goToPubDevFixDescription = "\u200BSee %s on pub.dev"
const val fixFamilyName = "Update package"
const val errorReportDescription =
"To help me fix this problem, you can send an anonymous crash report. This report will contain " +
"To help fix this problem, you can send an anonymous crash report. This report will contain " +
"information on the crash, including your device model, system version, the plugin’s version " +
"and build number. By sending this report you hereby agree to this policy."
const val errorReportButtonText = "Report to Author"
Expand Down

0 comments on commit 86a1628

Please sign in to comment.