Skip to content

Commit f390f3e

Browse files
committed
功能新增
1 parent f3c71a6 commit f390f3e

20 files changed

Lines changed: 753 additions & 224 deletions

.idea/workspace.xml

Lines changed: 190 additions & 163 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ val bPlugins = mutableListOf(
4646
"org.intellij.groovy"
4747
)
4848

49+
println(ideType)
4950
if (ideType.toInt() >= 243) {
5051
bPlugins.add("com.intellij.modules.json")
5152
bPlugins.add("com.intellij.platform.images")
52-
if(ideType != "253"){
53+
if(ideType.toInt() < 253) {
5354
bPlugins.add("org.intellij.intelliLang")
5455
}
55-
5656
}
5757

5858
dependencies {
@@ -82,14 +82,15 @@ dependencies {
8282
zipSigner()
8383
javaCompiler()
8484

85-
if(ideType == "253"){
86-
bundledModule("org.intellij.intelliLang")
87-
}
8885

89-
bundledModule("intellij.libraries.ktor.client")
90-
bundledModule("intellij.libraries.ktor.client.cio")
9186

92-
testBundledModules("intellij.libraries.ktor.client", "intellij.libraries.ktor.client.cio")
87+
if(ideType.toInt() < 253){
88+
bundledModule("intellij.libraries.ktor.client")
89+
bundledModule("intellij.libraries.ktor.client.cio")
90+
testBundledModules("intellij.libraries.ktor.client", "intellij.libraries.ktor.client.cio")
91+
testPlugins("Dart:$dartVersion")
92+
}
93+
9394

9495
testFramework(TestFrameworkType.Platform)
9596

@@ -151,7 +152,7 @@ tasks {
151152

152153
patchPluginXml {
153154
sinceBuild.set(sinceBuildVersion)
154-
untilBuild.set(untilBuildVersion)
155+
// untilBuild.set(untilBuildVersion)
155156
changeNotes.set(myChangeLog)
156157
pluginDescription.set(file("插件介绍h.md").readText().trim())
157158
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ideType=252
1212
#ideType=251
1313
#====================
1414
#253
15-
#dartVersion=253.17525.83
15+
#dartVersion=253.28086.9
1616
#sinceBuildVersion=253
1717
#untilBuildVersion=253.*
1818
#ideType=253

src/main/kotlin/shop/itbug/fluttercheckversionx/common/yaml/YamlFileTools.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
package shop.itbug.fluttercheckversionx.common.yaml
22

3+
import com.intellij.openapi.project.Project
4+
import com.intellij.openapi.project.guessProjectDir
5+
import com.intellij.psi.PsiManager
36
import kotlinx.coroutines.async
47
import kotlinx.coroutines.awaitAll
58
import kotlinx.coroutines.coroutineScope
69
import org.jetbrains.yaml.psi.YAMLFile
710
import org.jetbrains.yaml.psi.impl.YAMLKeyValueImpl
811
import shop.itbug.fluttercheckversionx.services.MyPackageGroup
912

13+
// 判断项目是否为 flutter 项目
14+
suspend fun Project.isFlutterProject(): Boolean {
15+
val baseDir = guessProjectDir() ?: return false
16+
val pubFile = baseDir.findChild("pubspec.yaml") ?: return false
17+
val pubPsiFile = PsiManager.getInstance(this).findFile(pubFile) as? YAMLFile? ?: return false
18+
return PubspecYamlFileTools.create(pubPsiFile).isFlutterProject()
19+
}
20+
1021
/**
1122
* flutter yaml 操作相关工具函数
1223
*/

src/main/kotlin/shop/itbug/fluttercheckversionx/document/DartDocumentExt.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class DartDocumentExt : AbstractDocumentationProvider(), ExternalDocumentationHa
5151
)
5252
if (result.isEmpty()) return "Document not found"
5353
val docInfo = result.first()
54+
println("kind类型:${docInfo.elementKind}")
5455
val dartFormalParameterList =
5556
reference?.parent?.children?.filterIsInstance<DartFormalParameterListImpl>() ?: emptyList()
5657
return renderView(

src/main/kotlin/shop/itbug/fluttercheckversionx/document/MarkdownRender.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fun MarkdownNode.toHtml(project: Project): String {
134134
nodeText = nodeText.replace("{@end-tool}", "</pre>")
135135
}
136136

137-
println("\nnode text: $nodeText ✅NodeType=$nodeType \n")
137+
// println("\nnode text: $nodeText ✅NodeType=$nodeType \n")
138138

139139
when (nodeType) {
140140
MarkdownElementTypes.UNORDERED_LIST -> wrapChildren("ul", newline = true)

src/main/kotlin/shop/itbug/fluttercheckversionx/services/AssetsListeningProjectService.kt

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.intellij.openapi.Disposable
77
import com.intellij.openapi.actionSystem.ActionUpdateThread
88
import com.intellij.openapi.actionSystem.AnActionEvent
99
import com.intellij.openapi.components.Service
10-
import com.intellij.openapi.diagnostic.thisLogger
10+
import com.intellij.openapi.components.service
1111
import com.intellij.openapi.progress.ProgressIndicator
1212
import com.intellij.openapi.progress.ProgressManager
1313
import com.intellij.openapi.progress.Task
@@ -30,7 +30,6 @@ import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig
3030
import shop.itbug.fluttercheckversionx.config.PluginConfig
3131
import shop.itbug.fluttercheckversionx.i18n.PluginBundle
3232
import shop.itbug.fluttercheckversionx.icons.MyIcons
33-
import shop.itbug.fluttercheckversionx.model.FlutterLocalVersion
3433
import shop.itbug.fluttercheckversionx.model.getVersionText
3534
import shop.itbug.fluttercheckversionx.tools.FlutterVersionTool
3635
import shop.itbug.fluttercheckversionx.util.DateUtils
@@ -40,7 +39,6 @@ import shop.itbug.fluttercheckversionx.util.Util
4039

4140
//
4241
class MyAssetGenPostStart : ProjectActivity {
43-
val logger = thisLogger()
4442
override suspend fun execute(project: Project) {
4543
AssetsListeningProjectService.getInstance(project).initListening()
4644
FlutterL10nService.getInstance(project).checkAllKeys()
@@ -49,10 +47,11 @@ class MyAssetGenPostStart : ProjectActivity {
4947
if (!project.isDisposed && setting.state.scanDartStringInStart) {
5048
FlutterL10nService.getInstance(project).startScanStringElements()
5149
}
52-
}
53-
5450

51+
}
5552
FlutterXVMService.getInstance(project)
53+
FlutterVersionService.getInstance(project).refreshAndGetFlutterVersion()
54+
project.service<DotMigrateService>()
5655
}
5756
}
5857

@@ -67,7 +66,6 @@ class MyProjectListening : ProjectManagerListener {
6766

6867
@Service(Service.Level.PROJECT)
6968
class AssetsListeningProjectService(val project: Project) : Disposable {
70-
private val logger = thisLogger()
7169
private val connect: MessageBusConnection = project.messageBus.connect(this)
7270
private var checkFlutterVersionTask: CheckFlutterVersionTask = CheckFlutterVersionTask()
7371

@@ -134,32 +132,20 @@ class AssetsListeningProjectService(val project: Project) : Disposable {
134132
}
135133

136134
///检测flutter新版本弹出
137-
private inner class CheckFlutterVersionTask() :
135+
private inner class CheckFlutterVersionTask :
138136
Task.Backgroundable(project, "Detecting Flutter version...") {
139137
var indication: ProgressIndicator? = null
140138
override fun run(indicator: ProgressIndicator) {
141139
this.indication = indicator
142-
val flutterChannel = Util.getFlutterChannel()
143-
val currentFlutterVersion: FlutterLocalVersion? =
144-
runBlocking { FlutterVersionTool.getLocalFlutterVersion(project) }
145-
if (flutterChannel == null) {
146-
return
147-
}
148-
currentFlutterVersion?.let { c ->
149-
try {
150-
val version = FlutterService.getVersion()
151-
version.apply {
152-
val hash = version.getCurrentReleaseByChannel(flutterChannel)
153-
val release = releases.find { o -> o.hash == hash }
154-
release?.let { r ->
155-
if (r.version != c.getVersionText()) {
156-
showTip(r, project)
157-
}
158-
}
159-
}
160-
} catch (e: Exception) {
161-
logger.warn("检查 flutter 版本失败:${e.localizedMessage}")
162-
}
140+
val flutterVersionService = FlutterVersionService.getInstance(project)
141+
val flutterChannel = Util.getFlutterChannel() ?: return
142+
val currentFlutterVersion =
143+
runBlocking { flutterVersionService.refreshAndGetFlutterVersion() } ?: return
144+
val version = flutterVersionService.getRemoteFlutterVersion() ?: return
145+
val hash = version.getCurrentReleaseByChannel(flutterChannel)
146+
val release = version.releases.find { o -> o.hash == hash } ?: return
147+
if (release.version != currentFlutterVersion.getVersionText()) {
148+
showTip(release, project)
163149
}
164150
}
165151

0 commit comments

Comments
 (0)