diff --git a/distribution/create_macos_app.sh b/distribution/create_macos_app.sh index dfead6c8..44d15786 100755 --- a/distribution/create_macos_app.sh +++ b/distribution/create_macos_app.sh @@ -44,8 +44,8 @@ cp "${RELEASE}"/taqo_daemon taqo_client/macos/TaqoLauncher/taqo_daemon # Build IntelliJ Plugin pushd pal_intellij_plugin || exit -./gradlew copyPlugin -cp "build/distributions/pal_intellij_plugin.zip" "../taqo_client/assets/" +dart --no-sound-null-safety builder/bin/builder.dart +cp build/distributions/pal_intellij_plugin-*.zip "../taqo_client/assets/" popd || exit # Build flutter app diff --git a/distribution/linux/build.sh b/distribution/linux/build.sh index 55ee3622..b2f4e3b0 100755 --- a/distribution/linux/build.sh +++ b/distribution/linux/build.sh @@ -54,6 +54,6 @@ popd || exit # Build IntelliJ Plugin pushd pal_intellij_plugin || exit -./gradlew copyPlugin -cp "build/distributions/pal_intellij_plugin.zip" "$OUT_DIR/" +dart --no-sound-null-safety builder/bin/builder.dart +cp build/distributions/pal_intellij_plugin-*.zip "$OUT_DIR/" popd || exit diff --git a/distribution/linux/debian-changelog.tpl b/distribution/linux/debian-changelog.tpl index 3445a0fc..d138ab9b 100644 --- a/distribution/linux/debian-changelog.tpl +++ b/distribution/linux/debian-changelog.tpl @@ -1,4 +1,4 @@ -taqosurvey (1.2.0) UNRELEASED; urgency=low +taqosurvey (1.3.0) UNRELEASED; urgency=low * Initial Release. diff --git a/pal_event_server/lib/src/loggers/intellij/intellij_logger.dart b/pal_event_server/lib/src/loggers/intellij/intellij_logger.dart index 251ffdda..23fdb1f9 100644 --- a/pal_event_server/lib/src/loggers/intellij/intellij_logger.dart +++ b/pal_event_server/lib/src/loggers/intellij/intellij_logger.dart @@ -22,8 +22,7 @@ import 'package:taqo_common/model/interrupt_cue.dart'; import '../../triggers/triggers.dart'; import '../loggers.dart'; -import 'linux/linux_helper.dart' as linux_helper; -import 'macos/macos_helper.dart' as macos_helper; +import 'intellij_plugin_helper.dart'; final _logger = Logger('IntelliJLogger'); @@ -53,11 +52,7 @@ class IntelliJLogger extends PacoEventLogger with EventTriggerSource { _logger.info('Starting IntelliJLogger'); active = true; - if (Platform.isLinux) { - linux_helper.enableIntelliJPlugin(); - } else if (Platform.isMacOS) { - macos_helper.enableIntelliJPlugin(); - } + enableIntelliJPlugin(); // Create Paco Events super.start(toLog, toTrigger); @@ -78,11 +73,7 @@ class IntelliJLogger extends PacoEventLogger with EventTriggerSource { _logger.info('Stopping IntelliJLogger'); active = false; - if (Platform.isLinux) { - linux_helper.disableIntelliJPlugin(); - } else if (Platform.isMacOS) { - macos_helper.disableIntelliJPlugin(); - } + disableIntelliJPlugin(); } } } diff --git a/pal_event_server/lib/src/loggers/intellij/intellij_plugin_helper.dart b/pal_event_server/lib/src/loggers/intellij/intellij_plugin_helper.dart new file mode 100644 index 00000000..97c290eb --- /dev/null +++ b/pal_event_server/lib/src/loggers/intellij/intellij_plugin_helper.dart @@ -0,0 +1,157 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// @dart=2.9 + +import 'dart:io'; + +import 'package:archive/archive.dart'; +import 'package:archive/archive_io.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; +import 'package:taqo_common/platform/platform.dart'; + +final _logger = Logger('IntelliJPluginHelper'); + +const intelliJAssetDirs = { + PlatformOs.linux: '/usr/lib/taqo/', + PlatformOs.macos: + '/Applications/Taqo.app/Contents/Frameworks/App.framework/Resources/flutter_assets/assets/' +}; +final homeDir = Directory(Platform.environment['HOME']); + +final searchPaths = { + PlatformOs.linux: [ + Directory(path.join(homeDir.path, '.local', 'share')), + Directory(path.join(homeDir.path, '.local', 'share', 'JetBrains')), + Directory(path.join(homeDir.path, '.local', 'share', 'Google')) + ], + PlatformOs.macos: [ + Directory(path.join(homeDir.path, 'Library', 'Application Support')), + Directory( + path.join(homeDir.path, 'Library', 'Application Support', 'JetBrains')), + Directory( + path.join(homeDir.path, 'Library', 'Application Support', 'Google')), + ] +}; + +final intelliJPaths = [ + RegExp(r'\.?(AndroidStudio[A-Za-z]*)(\d+\.\d+)'), + RegExp(r'\.?(IdeaI[CU])(\d{4}\.\d+)'), +]; + +String getPluginDir(Directory dir) { + if (Platform.isLinux) { + return dir.path; + } else if (Platform.isMacOS) { + return path.join(dir.path, 'plugins'); + } +} + +String extractVersionRepFromPluginFile(String pluginPath) { + final pluginRegExp = RegExp(r'pal_intellij_plugin-(\d+)\.\d+\.\d+\.zip'); + final pluginBase = path.basename(pluginPath); + var pluginMatch = pluginRegExp.firstMatch(pluginBase); + return pluginMatch?.group(1); +} + +String extractVersionRepFromIdeSupportFolder(String ideSupportPath) { + final ideSupportBase = path.basename(ideSupportPath); + for (var idePath in intelliJPaths) { + var ideMatch = idePath.firstMatch(ideSupportBase); + if (ideMatch != null) { + var ide = ideMatch.group(1); + var version = ideMatch.group(2); + _logger.info('Detected $ideSupportBase ($ide, version $version)'); + + if (ide.startsWith('AndroidStudio') && version == '4.2') { + return '202'; + } else if (RegExp(r'^\d{4}\.\d$').hasMatch(version)) { + // e.g. '2020.3' => '203' + return version.substring(2, 4) + version[5]; + } else { + _logger.info('Does not support $ideSupportBase'); + } + } + } + return null; +} + +Future> loadSupportedVersions() async { + final pluginRegExp = RegExp(r'(\d+)\.\d+\.\d+'); + final intelliJAssetDir = + Directory(intelliJAssetDirs[Platform.operatingSystem]); + var versionPathMap = {}; + await for (var asset in intelliJAssetDir.list()) { + var versionRep = extractVersionRepFromPluginFile(asset.path); + if (versionRep != null) { + _logger.info('Support IntelliJ version $versionRep at ${asset.path}'); + versionPathMap[versionRep] = asset.path; + } + } + return versionPathMap; +} + +void extractIntelliJPlugin(String directory, String pluginPath) async { + final zipFile = await File(pluginPath).readAsBytes(); + final pluginPkg = ZipDecoder().decodeBytes(zipFile); + + for (var item in pluginPkg) { + final output = path.join(directory, item.name); + if (item.isFile) { + final itemBytes = item.content as List; + final f = File(output); + await f.create(recursive: true); + await f.writeAsBytes(itemBytes); + } else { + final d = Directory(output); + await d.create(recursive: true); + } + } +} + +void enableIntelliJPlugin() async { + final versionPathMap = await loadSupportedVersions(); + for (var toCheck in searchPaths[Platform.operatingSystem]) { + await for (var dir in toCheck.list()) { + final versionRep = extractVersionRepFromIdeSupportFolder(dir.path); + if (versionRep != null) { + final pluginPath = versionPathMap[versionRep]; + if (pluginPath != null) { + await extractIntelliJPlugin(getPluginDir(dir), pluginPath); + } else { + _logger.info('IDE at ${dir.path} has no corresponding plugins.'); + } + } + } + } +} + +void disableIntelliJPlugin() async { + for (var toCheck in searchPaths[Platform.operatingSystem]) { + await for (var dir in toCheck.list()) { + final baseDir = path.basename(dir.path); + + for (var idePath in intelliJPaths) { + if (idePath.hasMatch(baseDir)) { + var d = + Directory(path.join(getPluginDir(dir), 'pal_intellij_plugin')); + if (await d.exists()) { + await d.delete(recursive: true); + } + } + } + } + } +} diff --git a/pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart b/pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart deleted file mode 100644 index 687e7f02..00000000 --- a/pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @dart=2.9 - -import 'dart:io'; - -import 'package:archive/archive.dart'; -import 'package:archive/archive_io.dart'; -import 'package:path/path.dart' as path; - -const intelliJAssetPath = '/usr/lib/taqo/pal_intellij_plugin.zip'; -final intelliJPaths = [ - RegExp(r'\.?AndroidStudio\d+\.\d+'), - RegExp(r'\.?IdeaIC\d{4}\.\d+'), -]; - -void extractIntelliJPlugin(String directory) async { - final zipFile = await File(intelliJAssetPath).readAsBytes(); - final pluginPkg = ZipDecoder().decodeBytes(zipFile); - - final oldPluginDir = Directory(path.join(directory, 'config', 'plugins')); - final newPluginDir = Directory(directory); - final pluginDir = await newPluginDir.exists() ? newPluginDir : oldPluginDir; - - for (var item in pluginPkg) { - final output = path.join(pluginDir.path, item.name); - if (item.isFile) { - final itemBytes = item.content as List; - final f = File(output); - await f.create(recursive: true); - await f.writeAsBytes(itemBytes); - } else { - final d = Directory(output); - await d.create(recursive: true); - } - } -} - -void enableIntelliJPlugin() async { - final homeDir = Directory(Platform.environment['HOME']); - final dirsToCheck = [ - homeDir, - Directory(path.join(homeDir.path, '.local', 'share')), - Directory(path.join(homeDir.path, '.local', 'share', 'JetBrains')), - ]; - - for (var toCheck in dirsToCheck) { - await for (var dir in toCheck.list()) { - final baseDir = path.basename(dir.path); - - for (var idePath in intelliJPaths) { - if (idePath.hasMatch(baseDir)) { - await extractIntelliJPlugin(dir.path); - } - } - } - } -} - -void disableIntelliJPlugin() async { - final homeDir = Directory(Platform.environment['HOME']); - final dirsToCheck = [ - homeDir, - Directory(path.join(homeDir.path, '.local', 'share')), - Directory(path.join(homeDir.path, '.local', 'share', 'JetBrains')), - ]; - - for (var toCheck in dirsToCheck) { - await for (var dir in toCheck.list()) { - final baseDir = path.basename(dir.path); - - for (var idePath in intelliJPaths) { - if (idePath.hasMatch(baseDir)) { - // Older versions of IntelliJ - var d = Directory( - path.join(dir.path, 'config', 'plugins', 'pal_intellij_plugin')); - if (await d.exists()) { - await d.delete(recursive: true); - } - - // Newer versions of IntelliJ - d = Directory(path.join(dir.path, 'pal_intellij_plugin')); - if (await d.exists()) { - await d.delete(recursive: true); - } - } - } - } - } -} diff --git a/pal_event_server/lib/src/loggers/intellij/macos/macos_helper.dart b/pal_event_server/lib/src/loggers/intellij/macos/macos_helper.dart deleted file mode 100644 index 96e4d9c2..00000000 --- a/pal_event_server/lib/src/loggers/intellij/macos/macos_helper.dart +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @dart=2.9 - -import 'dart:io'; - -import 'package:archive/archive.dart'; -import 'package:archive/archive_io.dart'; -import 'package:path/path.dart' as path; - -import 'package:taqo_common/storage/dart_file_storage.dart'; - -const intelliJAssetPath = - '/Applications/Taqo.app/Contents/Frameworks/App.framework/Resources/flutter_assets/assets/pal_intellij_plugin.zip'; - -void extractIntelliJPlugin(String directory) async { - final zipFile = await File(intelliJAssetPath).readAsBytes(); - final pluginPkg = ZipDecoder().decodeBytes(zipFile); - - for (var item in pluginPkg) { - final output = path.join(directory, item.name); - if (item.isFile) { - final itemBytes = item.content as List; - final f = File(output); - await f.create(recursive: true); - await f.writeAsBytes(itemBytes); - } else { - final d = Directory(output); - await d.create(recursive: true); - } - } -} - -void enableAndroidStudio() async { - final idePath = RegExp(r'AndroidStudio\d+\.\d+'); - final homeDir = Directory(path.join( - DartFileStorage.getHomePath(), 'Library', 'Application Support')); - - await for (var dir in homeDir.list()) { - final baseDir = path.basename(dir.path); - - if (idePath.hasMatch(baseDir)) { - await extractIntelliJPlugin(dir.path); - } - } -} - -void enableIntelliJ() async { - final idePath = RegExp(r'IdeaIC\d{4}\.\d+'); - final jetbrainsDir = Directory(path.join(DartFileStorage.getHomePath(), - 'Library', 'Application Support', 'JetBrains')); - - if (!(await jetbrainsDir.exists())) { - return; - } - - await for (var dir in jetbrainsDir.list()) { - final baseDir = path.basename(dir.path); - - if (idePath.hasMatch(baseDir)) { - await extractIntelliJPlugin(path.join(dir.path, 'plugins')); - } - } -} - -void enableIntelliJPlugin() async { - await enableAndroidStudio(); - await enableIntelliJ(); -} - -void disableAndroidStudio() async { - final idePath = RegExp(r'AndroidStudio\d+\.\d+'); - final homeDir = Directory(path.join( - DartFileStorage.getHomePath(), 'Library', 'Application Support')); - - await for (var dir in homeDir.list()) { - final baseDir = path.basename(dir.path); - - if (idePath.hasMatch(baseDir)) { - final d = Directory(path.join(dir.path, 'pal_intellij_plugin')); - if (await d.exists()) { - await d.delete(recursive: true); - } - } - } -} - -void disableIntelliJ() async { - final idePath = RegExp(r'IdeaIC\d{4}\.\d+'); - final jetbrainsDir = Directory(path.join(DartFileStorage.getHomePath(), - 'Library', 'Application Support', 'JetBrains')); - - await for (var dir in jetbrainsDir.list()) { - final baseDir = path.basename(dir.path); - - if (idePath.hasMatch(baseDir)) { - final d = - Directory(path.join(dir.path, 'plugins', 'pal_intellij_plugin')); - if (await d.exists()) { - await d.delete(recursive: true); - } - } - } -} - -void disableIntelliJPlugin() async { - await disableAndroidStudio(); - await disableIntelliJ(); -} diff --git a/pal_event_server/pubspec.lock b/pal_event_server/pubspec.lock index 03574e08..0a4377fe 100644 --- a/pal_event_server/pubspec.lock +++ b/pal_event_server/pubspec.lock @@ -8,6 +8,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.9" + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "14.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "0.41.2" archive: dependency: "direct main" description: @@ -29,6 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" charcode: dependency: transitive description: @@ -36,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.3" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" collection: dependency: "direct main" description: @@ -50,6 +78,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.2" crypto: dependency: transitive description: @@ -92,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" http_parser: dependency: transitive description: @@ -106,6 +148,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" js: dependency: transitive description: @@ -127,13 +176,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.11.4" - meta: + matcher: dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.9" + meta: + dependency: "direct overridden" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.6.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" node_interop: dependency: transitive description: @@ -148,6 +211,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.1" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.13" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" path: dependency: transitive description: @@ -169,6 +246,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.0" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" sembast: dependency: "direct main" description: @@ -176,6 +267,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.3.0" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.9" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.9+2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.4+1" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.9" source_span: dependency: transitive description: @@ -190,6 +323,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.6" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" string_scanner: dependency: transitive description: @@ -232,6 +379,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + test: + dependency: "direct dev" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.7" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.18+1" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.11+4" typed_data: dependency: transitive description: @@ -239,5 +407,40 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.6" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.0" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7+15" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.5" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" sdks: dart: ">=2.12.0 <3.0.0" diff --git a/pal_event_server/pubspec.yaml b/pal_event_server/pubspec.yaml index c6389e79..147934ad 100644 --- a/pal_event_server/pubspec.yaml +++ b/pal_event_server/pubspec.yaml @@ -30,3 +30,9 @@ dependencies: taqo_event_server_protocol: path: ../taqo_event_server_protocol collection: ^1.15.0-nullsafety.4 + +dev_dependencies: + test: any + +dependency_overrides: + meta: 1.6.0 diff --git a/pal_event_server/test/intellij_plugin_helper_test.dart b/pal_event_server/test/intellij_plugin_helper_test.dart new file mode 100644 index 00000000..e9b69587 --- /dev/null +++ b/pal_event_server/test/intellij_plugin_helper_test.dart @@ -0,0 +1,38 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// @dart=2.9 + +import 'package:test/test.dart'; +import 'package:pal_event_server/src/loggers/intellij/intellij_plugin_helper.dart'; + +void main() { + group('All', () { + test('extractVersionRepFromPluginFile', () { + expect(extractVersionRepFromPluginFile('paco256.png'), isNull); + expect(extractVersionRepFromPluginFile('pal_intellij_plugin-203.6682.168.zip'), equals('203')); + }); + + test('extractVersionRepFromIdeSupportFolder', () { + expect(extractVersionRepFromIdeSupportFolder('consentOptions'), isNull); + expect(extractVersionRepFromIdeSupportFolder('CLion2020.1'), isNull); + expect(extractVersionRepFromIdeSupportFolder('IdeaIC2020.1'), equals('201')); + expect(extractVersionRepFromIdeSupportFolder('IdeaIU2021.2'), equals('212')); + expect(extractVersionRepFromIdeSupportFolder('AndroidStudioPreview2021.1'), equals('211')); + expect(extractVersionRepFromIdeSupportFolder('AndroidStudioWithBlaze2020.3'), equals('203')); + expect(extractVersionRepFromIdeSupportFolder('AndroidStudio4.2'), equals('202')); + expect(extractVersionRepFromIdeSupportFolder('AndroidStudio4.1'), isNull); + }); + }); +} diff --git a/pal_intellij_plugin/build.gradle b/pal_intellij_plugin/build.gradle index 783049f0..8344e32b 100644 --- a/pal_intellij_plugin/build.gradle +++ b/pal_intellij_plugin/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'com.pacoapp' -version '1.2' +version "$buildVersion" repositories { mavenCentral() @@ -19,7 +19,7 @@ dependencies { // See https://github.com/JetBrains/gradle-intellij-plugin/ intellij { localPath "${project.rootDir.absolutePath}/artifacts/$ide" - plugins = ["java", "Dart:$dartPluginVersion", "io.flutter:$flutterPluginVersion"] + plugins = ["java"] } patchPluginXml { @@ -28,9 +28,18 @@ patchPluginXml { most HTML tags may be used""" } -task copyPlugin(type: Copy) { - from buildPlugin - into "$buildDir/distributions" - rename { String filenName -> "pal_intellij_plugin.zip"} - // rename { String filenName -> "pal_intellij_plugin-${buildVersion}.zip"} -} +//task copyPlugin(type: Copy) { +// from buildPlugin +// into "$buildDir/distributions" +// rename { String filenName -> "pal_intellij_plugin.zip"} +// // rename { String filenName -> "pal_intellij_plugin-${buildVersion}.zip"} +//} + +tasks { + instrumentCode { + compilerVersion = "$baseVersion" + } + instrumentTestCode { + compilerVersion = "$baseVersion" + } +} \ No newline at end of file diff --git a/pal_intellij_plugin/builder/lib/builder.dart b/pal_intellij_plugin/builder/lib/builder.dart index a37a4d04..7b34bc30 100644 --- a/pal_intellij_plugin/builder/lib/builder.dart +++ b/pal_intellij_plugin/builder/lib/builder.dart @@ -18,7 +18,7 @@ import 'flutter_intellij.dart'; import 'patches.dart'; final BuildSpec buildSpec = BuildSpec( - flutter_intellij_commit: '7793cfc', flutter_intellij_release: '58.0'); + flutter_intellij_commit: 'release_60', flutter_intellij_release: '60.1'); class BuildSpec { final String flutter_intellij_commit; @@ -46,15 +46,15 @@ class BuildSpec { } Future runGradleBuild() async { - var args = ['copyPlugin']; + var args = ['buildPlugin']; Process process; if (Platform.isWindows) { process = await Process.start('.\\gradlew.bat', args); } else { process = await Process.start('./gradlew', args); } - await stdout.addStream(process.stdout); - await stderr.addStream(process.stderr); + await Future.wait( + [stdout.addStream(process.stdout), stderr.addStream(process.stderr)]); } Future buildPlugins(BuildSpec spec) async { diff --git a/pal_intellij_plugin/builder/lib/flutter_intellij.dart b/pal_intellij_plugin/builder/lib/flutter_intellij.dart index e62909bd..7ddd2561 100644 --- a/pal_intellij_plugin/builder/lib/flutter_intellij.dart +++ b/pal_intellij_plugin/builder/lib/flutter_intellij.dart @@ -57,6 +57,7 @@ Future writeGradleProperties( dartPluginVersion = ${spec.dartPluginVersion} flutterPluginVersion = $release.$pluginCount buildVersion = ${spec.sinceBuild} +baseVersion = ${spec.baseVersion} '''; final propertiesFile = File('$rootPath/gradle.properties'); await propertiesFile.writeAsString(contents); diff --git a/pal_intellij_plugin/builder/pubspec.yaml b/pal_intellij_plugin/builder/pubspec.yaml index 4db45bc5..e84369da 100644 --- a/pal_intellij_plugin/builder/pubspec.yaml +++ b/pal_intellij_plugin/builder/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: git: url: https://github.com/flutter/flutter-intellij.git path: tool/plugin - ref: 7793cfc + ref: release_60 dev_dependencies: pedantic: ^1.10.0 diff --git a/pal_intellij_plugin/gradle.properties b/pal_intellij_plugin/gradle.properties index 83f11865..c3afa64d 100644 --- a/pal_intellij_plugin/gradle.properties +++ b/pal_intellij_plugin/gradle.properties @@ -1,4 +1,5 @@ ide = ideaIC -dartPluginVersion = 211.7628.1 -flutterPluginVersion = 58.0.3 -buildVersion = 211.6432.7 +dartPluginVersion = 212.3724.2 +flutterPluginVersion = 60.1.4 +buildVersion = 212.3724.25 +baseVersion = 212.4746.92 diff --git a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/CommandExecutionListener.java b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/CommandExecutionListener.java index 515d768e..37308014 100644 --- a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/CommandExecutionListener.java +++ b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/CommandExecutionListener.java @@ -235,8 +235,7 @@ private void createProjectCodeDiff(Project project) { } private boolean isActionFencePostForDiffing(AnAction anAction) { - return anAction.getClass().getName().equals("com.intellij.execution.ExecutorRegistryImpl$ExecutorAction") || - anAction.getClass().getName().equals("io.flutter.actions.ReloadFlutterAppRetarget"); + return anAction.getClass().getName().equals("com.intellij.execution.ExecutorRegistryImpl$ExecutorAction"); } private boolean cursorMovementAction(Class actionClass) { diff --git a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/FileListener.java b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/FileListener.java index 5134b410..7e07b95e 100644 --- a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/FileListener.java +++ b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/FileListener.java @@ -18,9 +18,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.vfs.*; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; -import com.jetbrains.lang.dart.analyzer.DartServerData; -import io.flutter.dart.DartPlugin; import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -97,22 +94,6 @@ private void recordSave(VirtualFileEvent event) { foundProject = project; } } - if (foundProject != null) { - DartAnalysisServerService analysisService = DartPlugin.getInstance().getAnalysisService(foundProject); - List errors = analysisService.getErrors(file); - if (errors.size() > 0) { - data.put("errors", String.valueOf(errors.size())); - for (int i = 0; i < errors.size(); i++) { - DartServerData.DartError error = errors.get(i); - String message = error.getMessage(); - String code = error.getCode(); - String severity = error.getSeverity(); - int offset = error.getOffset(); - String combined = "type=" + (error.isError() ? "Error" : "Not Error") + ", sev="+severity+", code=" + code + ", offset = " + offset + ", message=" + message; - data.put("error_"+i, combined); - } - } - } pacoAppComponent.appendPacoEvent(PacoIntellijEventTypes.EventType.DOCUMENT_SAVED, data); } diff --git a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoApplicationComponent.java b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoApplicationComponent.java index f3f74e58..ff5361a8 100644 --- a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoApplicationComponent.java +++ b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoApplicationComponent.java @@ -48,7 +48,6 @@ import com.pacoapp.paco.net.tesp.TespClient; import com.pacoapp.paco.net.tesp.message.request.TespRequestAddEvent; import com.pacoapp.paco.shared.model2.*; -import io.flutter.settings.FlutterSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joda.time.DateTime; @@ -141,7 +140,6 @@ public void run() { outputs.add(new Output("type", type.toString())); outputs.add(new Output("apps_used", getIdeVersion())); //TODO detect if we are in a flutter experiment to guard adding this output - outputs.add(new Output("flutterSetting_ReloadOnSave", isReloadOnSaveSet())); //outputs.add(new Output("ide", "IntelliJ IDEA"));0 if (data != null && data.keySet() != null) { for (String name : data.keySet()) { @@ -152,24 +150,6 @@ public void run() { } pacoEventsQueue.add(event); } - - private String isReloadOnSaveSet() { - try { - Class settings = this.getClass().getClassLoader().loadClass("io.flutter.settings.FlutterSettings"); - if (settings != null) { - FlutterSettings flutterSettings = FlutterSettings.getInstance(); - if (flutterSettings != null) { - return String.valueOf(flutterSettings.isReloadOnSave()); - } else { - return "unknown"; - } - } else { - return "Unknown"; - } - } catch (ClassNotFoundException e) { - return "Unknown"; - } - } }); } diff --git a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoProjectComponent.java b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoProjectComponent.java index 41ec659b..581517f6 100644 --- a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoProjectComponent.java +++ b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/PacoProjectComponent.java @@ -36,12 +36,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.io.ZipUtil; import com.intellij.util.messages.MessageBusConnection; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; -import com.jetbrains.lang.dart.analyzer.DartServerData; -import io.flutter.dart.DartPlugin; -import io.flutter.dart.FlutterDartAnalysisServer; -import io.flutter.dart.FlutterOutlineListener; -import org.dartlang.analysis.server.protocol.FlutterOutline; import org.jetbrains.annotations.NotNull; import org.joda.time.DateTime; @@ -60,11 +54,7 @@ public class PacoProjectComponent implements ProjectComponent { private final Project project; private MessageBusConnection connection; - private FlutterDartAnalysisServer flutterDartAnalysisServer; - private FlutterOutlineListener outlineListener; private String outlineListenerFilePath; - private static final String FLUTTER_NOTIFICATION_OUTLINE = "flutter.outline"; - private DartAnalysisServerService dartAnalysisServerService; public PacoProjectComponent(Project project) { this.project = project; @@ -79,7 +69,6 @@ public void projectOpened() { pacoAppComponent.addRunManagerListener(project); pacoAppComponent.addFileEditorManagerListener(project); registerCompilerListener(project); - registerDartAnalysisListener(project); registerChangelistManagerListener(project); createSnapshotOfFiles(project, pacoAppComponent); } @@ -274,52 +263,13 @@ public void changeListUpdateDone() { changeListManager.addChangeListListener(changeListListener); } - private void registerDartAnalysisListener(Project project) { - JobScheduler.getScheduler().scheduleWithFixedDelay(() -> { - final DartAnalysisServerService analysisService = DartPlugin.getInstance().getAnalysisService(project); - if (analysisService != null) { - dartAnalysisServerService = analysisService; - } - }, 100, 100, TimeUnit.MILLISECONDS); -// flutterDartAnalysisServer = FlutterDartAnalysisServer.getInstance(project); -// -// flutterDartAnalysisServer.addOutlineListener(outlineListenerFilePath, outlineListener); - } - - public void getErrors(VirtualFile file) { - if (dartAnalysisServerService != null) { -// final String id = dartServiceEx.generateUniqueId(); -// -// JsonObject request = new JsonObject(); -// -// request.addProperty("id", id); -// request.addProperty("method", "analysis.getErrors"); -// JsonObject params = new JsonObject(); -// params.add("file", new JsonPrimitive("/Users/bobevans/IdeaProjects/my_test_flutter/lib/main.dart")); -// request.add("params", params); - - List errors = dartAnalysisServerService.getErrors(file); - } - } - private void processNotification(JsonObject response) { final JsonElement eventElement = response.get("event"); if (eventElement == null || !eventElement.isJsonPrimitive()) { return; } final String event = eventElement.getAsString(); - if (event.equals(FLUTTER_NOTIFICATION_OUTLINE)) { - final JsonObject paramsObject = response.get("params").getAsJsonObject(); - final String file = paramsObject.get("file").getAsString(); - - final JsonElement instrumentedCodeElement = paramsObject.get("instrumentedCode"); - final String instrumentedCode = instrumentedCodeElement != null ? instrumentedCodeElement.getAsString() : null; - - final JsonObject outlineObject = paramsObject.get("outline").getAsJsonObject(); - final FlutterOutline outline = FlutterOutline.fromJson(outlineObject); - log.info("outline = " + outline.toString()); - - } else if (event.equals("analysis.errors")) { + if (event.equals("analysis.errors")) { final JsonObject paramsObject = response.get("params").getAsJsonObject(); final String file = paramsObject.get("file").getAsString(); JsonArray errorArray = paramsObject.get("errors").getAsJsonArray(); diff --git a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/launch/PacoBeforeRunTaskProvider.java b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/launch/PacoBeforeRunTaskProvider.java index b3635d62..4bf7681d 100644 --- a/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/launch/PacoBeforeRunTaskProvider.java +++ b/pal_intellij_plugin/src/main/java/com/pacoapp/intellij/launch/PacoBeforeRunTaskProvider.java @@ -24,8 +24,6 @@ import com.intellij.openapi.util.WriteExternalException; import com.pacoapp.intellij.PacoApplicationComponent; import com.pacoapp.intellij.PacoIntellijEventTypes; -import io.flutter.run.FlutterDevice; -import io.flutter.run.daemon.DeviceService; import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -86,18 +84,13 @@ public boolean executeTask(DataContext context, final RunConfiguration configura String projectName = env.getProject().getName(); String configurationName = configuration.getName(); String configurtationType = env.getExecutor().getActionName(); - FlutterDevice device = DeviceService.getInstance(env.getProject()).getSelectedDevice(); Map data = Maps.newHashMap(); data.put("project", projectName); data.put("run_configuration_name", configurationName); data.put("run_configuration_action", configurtationType); data.put("run_configuration_type", runTypeName); - if (device != null) { - data.put("device_name", device.deviceName()); - data.put("device_platform", device.platform()); - data.put("device_emulator", String.valueOf(device.emulator())); - } + PacoApplicationComponent.appendPacoEvent(PacoIntellijEventTypes.EventType.LAUNCH, data); } catch (WriteExternalException e) { } diff --git a/pal_intellij_plugin/src/main/resources/META-INF/plugin.xml b/pal_intellij_plugin/src/main/resources/META-INF/plugin.xml index efd8b356..7bf0c73e 100644 --- a/pal_intellij_plugin/src/main/resources/META-INF/plugin.xml +++ b/pal_intellij_plugin/src/main/resources/META-INF/plugin.xml @@ -13,8 +13,6 @@ com.intellij.modules.platform --> com.intellij.modules.java - io.flutter - Dart diff --git a/resolve_deps.sh b/resolve_deps.sh index b768b508..c286411e 100755 --- a/resolve_deps.sh +++ b/resolve_deps.sh @@ -37,3 +37,6 @@ pushd pal_event_server || exit "$DART_SDK"/bin/pub get popd || exit +pushd pal_intellij_plugin/builder || exit +"$DART_SDK"/bin/pub get +popd || exit diff --git a/taqo_client/pubspec.yaml b/taqo_client/pubspec.yaml index bf650e6c..86dd5f1f 100644 --- a/taqo_client/pubspec.yaml +++ b/taqo_client/pubspec.yaml @@ -21,7 +21,7 @@ description: A tool for rendering surveys # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # Read more about versioning at semver.org. -version: 1.0.0+1 +version: 1.3.0 environment: sdk: '>=2.12.0 <3.0.0' diff --git a/taqo_common/lib/platform/platform.dart b/taqo_common/lib/platform/platform.dart new file mode 100644 index 00000000..f6d9b87a --- /dev/null +++ b/taqo_common/lib/platform/platform.dart @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// String representations of operating systems supported by Dart, as defined in +// https://github.com/dart-lang/sdk/blob/065872e802209ffa97aa3fad204758830b6100a0/sdk/lib/io/platform.dart#L88 + +class PlatformOs { + static const linux = 'linux'; + static const macos = 'macos'; + static const windows = 'windows'; + static const ios = 'ios'; + static const android = 'android'; + static const fuchsia = 'fuchsia'; +}