Skip to content

Commit 6012641

Browse files
authored
[perf] FlutterNewProjectAction stop eager presentation instantiation (#8504)
Stop eager presentation instantiation <img width="1226" height="152" alt="image" src="https://github.com/user-attachments/assets/00d94eb7-d289-4555-a932-30a8b15fe150" /> From the inspection: > Any of the constructors of AnAction with parameters instantiate the Presentation object. However, instantiating the Presentation object in constructor results in allocating resources, which may not be necessary. Instead of creating an instance of Presentation that stores text, description, or icon, it is more efficient to utilize no-argument constructors of AnAction and other base classes and follow the convention for setting the text, description, and icon in plugin.xml. The IDE will load text, description, and icon only when the action is actually displayed in the UI. Confirmed that the label set in `plugin.xml` is sufficient: <img width="1002" height="364" alt="image" src="https://github.com/user-attachments/assets/84b0586f-c4ab-4039-8881-5eb725b995ed" /> --- <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent 4b43c8d commit 6012641

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/io/flutter/FlutterBundle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ settings.enable.logs.preserve.during.hot.reload.and.restart=Preserve console log
158158
settings.enable.file.path.logging=Allow logging of full file paths
159159
settings.enable.file.path.logging.tooltip=Logs full file paths that could show private user information
160160

161-
action.new.project.title=New Flutter Project...
162161
welcome.new.project.compact=New Flutter Project
163162

164163
npw_platform_android=Android

src/io/flutter/actions/FlutterNewProjectAction.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider
1616
import com.intellij.openapi.wm.impl.welcomeScreen.NewWelcomeScreen
1717
import io.flutter.FlutterBundle
1818
import io.flutter.FlutterUtils
19-
import kotlinx.coroutines.DelicateCoroutinesApi
20-
import kotlinx.coroutines.Dispatchers
21-
import kotlinx.coroutines.GlobalScope
22-
import kotlinx.coroutines.launch
23-
import kotlinx.coroutines.withContext
19+
import kotlinx.coroutines.*
2420

2521
/**
2622
* This classes was re-implemented with Kotlin from FlutterNewProjectAction.java to resolve the New Flutter Project action from hanging,
2723
* https://github.com/flutter/flutter-intellij/issues/8310.
2824
*
2925
* See https://github.com/JetBrains/intellij-community/blob/master/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.kt
3026
*/
31-
class FlutterNewProjectAction : AnAction(FlutterBundle.message("action.new.project.title")), DumbAware {
27+
class FlutterNewProjectAction : AnAction(), DumbAware {
3228
override fun update(e: AnActionEvent) {
3329
if (NewWelcomeScreen.isNewWelcomeScreen(e)) {
3430
e.presentation.setText(FlutterBundle.message("welcome.new.project.compact"))

0 commit comments

Comments
 (0)