From d328f4e64f89a0ade5dfad304d233be6c6c2278e Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 8 Jun 2018 15:10:54 -0700 Subject: [PATCH] Enforce clang-format on all files in commit (#5495) * Enforce clang-format on all files in commit This re-enforces clang-format across all files changed in the commit. In c10c417, we enabled checking only for the lines changed in the diff in order to reduce the change of merge conflicts with the shell refactor landed in 58e84c8. * Reformat sources to match latest clang-format As part of re-enabling clang-format across the codebase, reformat all code to match the latest toolchain. --- .../framework/Source/FlutterPlatformPlugin.mm | 11 +++++----- .../Source/FlutterTextInputPlugin.mm | 2 +- .../framework/Source/accessibility_bridge.mm | 12 ++++++----- .../Source/accessibility_text_entry.mm | 3 ++- travis/format.sh | 21 +++++++++++++------ 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index eae9e51ffa9..4508599757a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -83,13 +83,14 @@ using namespace shell; } if (@available(iOS 10, *)) { - if ([@"HapticFeedbackType.lightImpact" isEqualToString: feedbackType]) { + if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) { [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] impactOccurred]; - } else if ([@"HapticFeedbackType.mediumImpact" isEqualToString: feedbackType]) { - [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] impactOccurred]; - } else if ([@"HapticFeedbackType.heavyImpact" isEqualToString: feedbackType]) { + } else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) { + [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] + impactOccurred]; + } else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) { [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] impactOccurred]; - } else if ([@"HapticFeedbackType.selectionClick" isEqualToString: feedbackType]) { + } else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) { [[[UISelectionFeedbackGenerator alloc] init] selectionChanged]; } } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 2a9f6b62ec1..79aee477a36 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -95,7 +95,7 @@ static UITextAutocapitalizationType ToUITextAutocapitalizationType(NSString* inp @end -@interface FlutterTextInputView : UIView +@interface FlutterTextInputView : UIView // UITextInput @property(nonatomic, readonly) NSMutableString* text; diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index dcfbf7dcfeb..f923581e7f0 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -159,7 +159,8 @@ blink::SemanticsAction GetSemanticsActionForScrollDirection( // We enforce in the framework that no other useful semantics are merged with these nodes. if ([self node].HasFlag(blink::SemanticsFlags::kScopesRoute)) return false; - return ([self node].flags != 0 && [self node].flags != static_cast(blink::SemanticsFlags::kIsHidden)) || + return ([self node].flags != 0 && + [self node].flags != static_cast(blink::SemanticsFlags::kIsHidden)) || ![self node].label.empty() || ![self node].value.empty() || ![self node].hint.empty() || ([self node].actions & ~blink::kScrollableSemanticsActions) != 0; } @@ -219,7 +220,7 @@ blink::SemanticsAction GetSemanticsActionForScrollDirection( return [self globalRect]; } -- (CGRect) globalRect { +- (CGRect)globalRect { SkMatrix44 globalTransform = [self node].transform; for (SemanticsObject* parent = [self parent]; parent; parent = parent.parent) { globalTransform = parent.node.transform * globalTransform; @@ -513,7 +514,8 @@ void AccessibilityBridge::UpdateSemantics(blink::SemanticsNodeUpdates nodes) { NSMutableArray* newRoutes = [[[NSMutableArray alloc] init] autorelease]; [root collectRoutes:newRoutes]; for (SemanticsObject* route in newRoutes) { - if (std::find(previous_routes_.begin(), previous_routes_.end(), [route uid]) != previous_routes_.end()) { + if (std::find(previous_routes_.begin(), previous_routes_.end(), [route uid]) != + previous_routes_.end()) { lastAdded = route; } } @@ -522,8 +524,8 @@ void AccessibilityBridge::UpdateSemantics(blink::SemanticsNodeUpdates nodes) { lastAdded = [newRoutes objectAtIndex:index]; } if (lastAdded != nil && [lastAdded uid] != previous_route_id_) { - previous_route_id_ = [lastAdded uid]; - routeChanged = true; + previous_route_id_ = [lastAdded uid]; + routeChanged = true; } previous_routes_.clear(); for (SemanticsObject* route in newRoutes) { diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm b/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm index 6dbfd3b56b8..ec98c5d0032 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm @@ -261,7 +261,8 @@ // Adding UIAccessibilityTraitKeyboardKey to the trait list so that iOS treats it like // a keyboard entry control, thus adding support for text editing features, such as // pinch to select text, and up/down fling to move cursor. - return [super accessibilityTraits] | [self textInputSurrogate].accessibilityTraits | UIAccessibilityTraitKeyboardKey; + return [super accessibilityTraits] | [self textInputSurrogate].accessibilityTraits | + UIAccessibilityTraitKeyboardKey; } #pragma mark - UITextInput overrides diff --git a/travis/format.sh b/travis/format.sh index 277ced4084b..8cc0d95cfe5 100755 --- a/travis/format.sh +++ b/travis/format.sh @@ -27,17 +27,26 @@ esac # Tools CLANG_FORMAT="../buildtools/$OS/clang/bin/clang-format" -CLANG_FORMAT_DIFF="../buildtools/$OS/clang/share/clang/clang-format-diff.py" $CLANG_FORMAT --version # Compute the diffs. FILETYPES="*.c *.cc *.cpp *.h *.m *.mm" -DIFF_OPTS="-U0 --no-color" -DIFFS="$(git diff $DIFF_OPTS -- master $FILETYPES | "$CLANG_FORMAT_DIFF" -p1 -binary "$CLANG_FORMAT")" +DIFF_OPTS="-U0 --no-color --name-only" +FILES_TO_CHECK="$(git diff $DIFF_OPTS -- master $FILETYPES)" -if [[ ! -z "$DIFFS" ]]; then +FAILED_CHECKS=0 +for f in $FILES_TO_CHECK; do + set +e + CUR_DIFF="$(diff -u "$f" <("$CLANG_FORMAT" --style=file "$f"))" + set -e + if [[ ! -z "$CUR_DIFF" ]]; then + echo "$CUR_DIFF" + FAILED_CHECKS=$(($FAILED_CHECKS+1)) + fi +done + +if [[ $FAILED_CHECKS -ne 0 ]]; then echo "" - echo "ERROR: Some files are formatted incorrectly. To fix, apply diffs below via patch -p0:" - echo "$DIFFS" + echo "ERROR: Some files are formatted incorrectly. To fix, apply diffs above via patch -p0." exit 1 fi