Skip to content

Commit

Permalink
[all] Fix formatting issues (#832)
Browse files Browse the repository at this point in the history
* formatting fixes

* format Objective-C code in default style and not in Google style

* quick format

* add cpp, m, h files to editorconfig
  • Loading branch information
miquelbeltran committed Apr 11, 2022
1 parent f0aaddd commit 9070b24
Show file tree
Hide file tree
Showing 106 changed files with 1,059 additions and 962 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Expand Up @@ -7,6 +7,10 @@ insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.cpp]
indent_style = space
indent_size = 2

[*.dart]
indent_style = space
indent_size = 2
Expand All @@ -16,10 +20,18 @@ indent_size = 2
indent_style = space
indent_size = 4

[*.h]
indent_style = space
indent_size = 2

# Kotlin code style according to https://developer.android.com/kotlin/style-guide
[*.{kt, kts}]
indent_size = 4
max_line_length = 100

[*.m]
indent_style = space
indent_size = 2

[*.yml]
indent_size = 2
2 changes: 1 addition & 1 deletion .github/workflows/all_plugins.yaml
Expand Up @@ -101,7 +101,7 @@ jobs:
if: ${{ success() || failure() }}
run: |
melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" -- \
find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --style=Google --verbose
find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --verbose
./.github/workflows/scripts/validate-formatting.sh
- name: "Validate Java formatting"
if: ${{ success() || failure() }}
Expand Down
Expand Up @@ -5,16 +5,18 @@
#import "AndroidAlarmManagerPlusPlugin.h"

@implementation FLTAndroidAlarmManagerPlusPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel =
[FlutterMethodChannel methodChannelWithName:@"dev.fluttercommunity.plus/android_alarm_manager"
binaryMessenger:[registrar messenger]
codec:[FlutterJSONMethodCodec sharedInstance]];
FLTAndroidAlarmManagerPlusPlugin* instance = [[FLTAndroidAlarmManagerPlusPlugin alloc] init];
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:@"dev.fluttercommunity.plus/android_alarm_manager"
binaryMessenger:[registrar messenger]
codec:[FlutterJSONMethodCodec sharedInstance]];
FLTAndroidAlarmManagerPlusPlugin *instance =
[[FLTAndroidAlarmManagerPlusPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
- (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result {
result(FlutterMethodNotImplemented);
}

Expand Down
Expand Up @@ -11,7 +11,8 @@ - (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
return [super application:application
didFinishLaunchingWithOptions:launchOptions];
}

@end
7 changes: 4 additions & 3 deletions packages/android_intent_plus/example/ios/Runner/main.m
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "AppDelegate.h"
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return UIApplicationMain(argc, argv, nil,
NSStringFromClass([AppDelegate class]));
}
}
2 changes: 1 addition & 1 deletion packages/battery_plus/battery_plus/example/linux/main.cc
@@ -1,6 +1,6 @@
#include "my_application.h"

int main(int argc, char** argv) {
int main(int argc, char **argv) {
// Only X11 is currently supported.
// Wayland support is being developed:
// https://github.com/flutter/flutter/issues/57932.
Expand Down
Expand Up @@ -11,10 +11,10 @@ struct _MyApplication {
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)

// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
GtkWindow* window =
static void my_application_activate(GApplication *application) {
GtkWindow *window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "example");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
Expand All @@ -24,7 +24,7 @@ static void my_application_activate(GApplication* application) {

g_autoptr(FlDartProject) project = fl_dart_project_new();

FlView* view = fl_view_new(project);
FlView *view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));

Expand All @@ -33,13 +33,13 @@ static void my_application_activate(GApplication* application) {
gtk_widget_grab_focus(GTK_WIDGET(view));
}

static void my_application_class_init(MyApplicationClass* klass) {
static void my_application_class_init(MyApplicationClass *klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
}

static void my_application_init(MyApplication* self) {}
static void my_application_init(MyApplication *self) {}

MyApplication* my_application_new() {
MyApplication *my_application_new() {
return MY_APPLICATION(g_object_new(
my_application_get_type(), "application-id", APPLICATION_ID, nullptr));
}
Expand Up @@ -13,6 +13,6 @@ G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
MyApplication *my_application_new();

#endif // FLUTTER_MY_APPLICATION_H_
#endif // FLUTTER_MY_APPLICATION_H_
Expand Up @@ -4,8 +4,8 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project)
FlutterWindow::FlutterWindow(RunLoop *run_loop,
const flutter::DartProject &project)
: run_loop_(run_loop), project_(project) {}

FlutterWindow::~FlutterWindow() {}
Expand Down Expand Up @@ -55,9 +55,9 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
}

switch (message) {
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
}

return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
Expand Down
Expand Up @@ -11,23 +11,23 @@

// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
public:
// Creates a new FlutterWindow driven by the |run_loop|, hosting a
// Flutter view running |project|.
explicit FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project);
explicit FlutterWindow(RunLoop *run_loop,
const flutter::DartProject &project);
virtual ~FlutterWindow();

protected:
protected:
// Win32Window:
bool OnCreate() override;
void OnDestroy() override;
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept override;

private:
private:
// The run loop driving events for this window.
RunLoop* run_loop_;
RunLoop *run_loop_;

// The project to run.
flutter::DartProject project_;
Expand All @@ -36,4 +36,4 @@ class FlutterWindow : public Win32Window {
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
};

#endif // RUNNER_FLUTTER_WINDOW_H_
#endif // RUNNER_FLUTTER_WINDOW_H_
Expand Up @@ -44,12 +44,12 @@ void RunLoop::Run() {
}

void RunLoop::RegisterFlutterInstance(
flutter::FlutterEngine* flutter_instance) {
flutter::FlutterEngine *flutter_instance) {
flutter_instances_.insert(flutter_instance);
}

void RunLoop::UnregisterFlutterInstance(
flutter::FlutterEngine* flutter_instance) {
flutter::FlutterEngine *flutter_instance) {
flutter_instances_.erase(flutter_instance);
}

Expand Down
Expand Up @@ -9,30 +9,30 @@
// A runloop that will service events for Flutter instances as well
// as native messages.
class RunLoop {
public:
public:
RunLoop();
~RunLoop();

// Prevent copying
RunLoop(RunLoop const&) = delete;
RunLoop& operator=(RunLoop const&) = delete;
RunLoop(RunLoop const &) = delete;
RunLoop &operator=(RunLoop const &) = delete;

// Runs the run loop until the application quits.
void Run();

// Registers the given Flutter instance for event servicing.
void RegisterFlutterInstance(flutter::FlutterEngine* flutter_instance);
void RegisterFlutterInstance(flutter::FlutterEngine *flutter_instance);

// Unregisters the given Flutter instance from event servicing.
void UnregisterFlutterInstance(flutter::FlutterEngine* flutter_instance);
void UnregisterFlutterInstance(flutter::FlutterEngine *flutter_instance);

private:
private:
using TimePoint = std::chrono::steady_clock::time_point;

// Processes all currently pending messages for registered Flutter instances.
TimePoint ProcessFlutterMessages();

std::set<flutter::FlutterEngine*> flutter_instances_;
std::set<flutter::FlutterEngine *> flutter_instances_;
};

#endif // RUNNER_RUN_LOOP_H_
#endif // RUNNER_RUN_LOOP_H_
Expand Up @@ -5,4 +5,4 @@
// it for both the runner and the Flutter library.
void CreateAndAttachConsole();

#endif // RUNNER_UTILS_H_
#endif // RUNNER_UTILS_H_

0 comments on commit 9070b24

Please sign in to comment.