From 51d3daadfb5b516555cccc1e447432e39a8c855c Mon Sep 17 00:00:00 2001 From: Stanislav Baranov Date: Mon, 30 Jul 2018 10:15:26 -0700 Subject: [PATCH] Change 'flutter ide-config' to optionally create root Intellij module (#19920) --- .../{modules.xml.copy.tmpl => modules.xml.tmpl} | 3 +++ .../intellij/flutter_root.iml.copy.tmpl | 8 ++++++++ .../flutter_tools/lib/src/commands/ide_config.dart | 12 +++++++++++- packages/flutter_tools/lib/src/template.dart | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) rename packages/flutter_tools/ide_templates/intellij/.idea/{modules.xml.copy.tmpl => modules.xml.tmpl} (95%) create mode 100644 packages/flutter_tools/ide_templates/intellij/flutter_root.iml.copy.tmpl diff --git a/packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.copy.tmpl b/packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.tmpl similarity index 95% rename from packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.copy.tmpl rename to packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.tmpl index 65465354193..eec528e08dd 100644 --- a/packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.copy.tmpl +++ b/packages/flutter_tools/ide_templates/intellij/.idea/modules.xml.tmpl @@ -2,6 +2,9 @@ +{{#withRootModule}} + +{{/withRootModule}} diff --git a/packages/flutter_tools/ide_templates/intellij/flutter_root.iml.copy.tmpl b/packages/flutter_tools/ide_templates/intellij/flutter_root.iml.copy.tmpl new file mode 100644 index 00000000000..80cc7391bd4 --- /dev/null +++ b/packages/flutter_tools/ide_templates/intellij/flutter_root.iml.copy.tmpl @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packages/flutter_tools/lib/src/commands/ide_config.dart b/packages/flutter_tools/lib/src/commands/ide_config.dart index f392917a480..73c52235c92 100644 --- a/packages/flutter_tools/lib/src/commands/ide_config.dart +++ b/packages/flutter_tools/lib/src/commands/ide_config.dart @@ -29,6 +29,14 @@ class IdeConfigCommand extends FlutterCommand { 'update any out-of-date files, and remove any deleted files from the ' 'template directory.', ); + argParser.addFlag( + 'with-root-module', + negatable: true, + defaultsTo: true, + help: 'Also create module that corresponds to the root of Flutter tree. ' + 'This makes the entire Flutter tree browsable and searchable in IDE. ' + 'Without this flag, only the child modules will be visible in IDE.', + ); } @override @@ -238,7 +246,9 @@ class IdeConfigCommand extends FlutterCommand { printStatus('Updating IDE configuration for Flutter tree at $dirPath...'); int generatedCount = 0; - generatedCount += _renderTemplate(_ideName, dirPath, {}); + generatedCount += _renderTemplate(_ideName, dirPath, { + 'withRootModule': argResults['with-root-module'], + }); printStatus('Wrote $generatedCount files.'); printStatus(''); diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart index 3f2221145d5..ab998586af5 100644 --- a/packages/flutter_tools/lib/src/template.dart +++ b/packages/flutter_tools/lib/src/template.dart @@ -107,6 +107,10 @@ class Template { } _templateFilePaths.forEach((String relativeDestinationPath, String absoluteSourcePath) { + final bool withRootModule = context['withRootModule'] ?? false; + if (!withRootModule && absoluteSourcePath.contains('flutter_root')) + return; + final String finalDestinationPath = renderPath(relativeDestinationPath); if (finalDestinationPath == null) return;