-
Notifications
You must be signed in to change notification settings - Fork 9.6k
upgraded usage of BinaryMessenger #4451
Changes from 3 commits
d0d9362
755e897
a5021dd
8c69fa1
34980e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
| // | ||
| // stable_conditional.dart | ||
| // | ||
| // Performs simple find and replace operations for conditional compilation | ||
| // before executing stable channel tests. | ||
| // | ||
| // Example input: | ||
| // int main() { | ||
| // // FLUTTER_STABLE_CHANNEL_BEGIN | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This naming is really confusing to me, since the name right after this is what is not going to be on the stable channel. What if we reverse it and do:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, that makes sense. With this naming "FLUTTER_STABLE_CHANNEL_" was just meant as a prefix for who is operating and not meant to be read as having meaning for the operation. Is there some way we can name it so that the master channel is on the top? I think it's easier to read the code if what is going to be happening the majority of the time is closer to the place where it will be. The exceptional code should be farther away. That way the prefix matches the name of the script, it keeps the naming similar to what you want but keeps the exceptional case at the bottom.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| // printf("hello world\n"); | ||
| // // FLUTTER_STABLE_CHANNEL_REPLACE | ||
| // // printf("goodbye world\n"); | ||
| // // FLUTTER_STABLE_CHANNEL_END | ||
| // } | ||
| // | ||
| // Example output: | ||
| // int main() { | ||
| // printf("goodbye world\n"); | ||
| // } | ||
|
|
||
| import 'dart:convert' show LineSplitter; | ||
| import 'dart:io' show Directory, FileSystemEntity, File; | ||
|
|
||
| final RegExp _isSourceRegex = | ||
| RegExp(r'\.cc$|\.java$|\.m$\.h$|\.c$|\.swift$|\.kt$'); | ||
| final RegExp _replacer = RegExp( | ||
| r'^\s*// FLUTTER_STABLE_CHANNEL_BEGIN(.*?)^\s*// FLUTTER_STABLE_CHANNEL_REPLACE(.*?)^\s*// FLUTTER_STABLE_CHANNEL_END', | ||
| multiLine: true, | ||
| dotAll: true); | ||
| final RegExp _commentRemover = RegExp(r'^(\s*)\/+\s*(.*)'); | ||
|
gaaclarke marked this conversation as resolved.
Outdated
|
||
| const String _newline = '\n'; | ||
|
|
||
| bool _isSourceFile(FileSystemEntity entity) => | ||
| _isSourceRegex.hasMatch(entity.path); | ||
|
gaaclarke marked this conversation as resolved.
Outdated
|
||
|
|
||
| void _process(FileSystemEntity entity) { | ||
| const LineSplitter splitter = LineSplitter(); | ||
| final String text = File(entity.path).readAsStringSync(); | ||
| String replaced = ''; | ||
| int index = 0; | ||
| for (final RegExpMatch match in _replacer.allMatches(text)) { | ||
| replaced += text.substring(index, match.start); | ||
| for (final String line in splitter.convert(match.group(2)!)) { | ||
| final RegExpMatch? commentRemoverMatch = _commentRemover.firstMatch(line); | ||
| if (commentRemoverMatch != null) { | ||
| replaced += commentRemoverMatch.group(1)! + | ||
| commentRemoverMatch.group(2)! + | ||
| _newline; | ||
| } | ||
| } | ||
| index = match.end; | ||
| } | ||
| if (replaced.isNotEmpty) { | ||
| replaced += text.substring(index, text.length); | ||
| File(entity.path).writeAsStringSync(replaced); | ||
| print('modified: ${entity.path}'); | ||
| } | ||
| } | ||
|
|
||
| void main(List<String> args) { | ||
| final String channel = args[0]; | ||
| if (channel == 'stable') { | ||
| final Directory dir = Directory('.'); | ||
| dir.list(recursive: true).where(_isSourceFile).forEach(_process); | ||
|
gaaclarke marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.