[all-commits] [llvm/llvm-project] 02656f: clang-format: [JS] options for arrow functions.

Martin Probst via All-commits all-commits at lists.llvm.org
Mon Jan 27 07:27:33 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 02656f29abda4eedd22e3b2b30bf2f422983514e
      https://github.com/llvm/llvm-project/commit/02656f29abda4eedd22e3b2b30bf2f422983514e
  Author: Martin Probst <martin at probst.io>
  Date:   2020-01-27 (Mon, 27 Jan 2020)

  Changed paths:
    M clang/lib/Format/Format.cpp
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTestJS.cpp

  Log Message:
  -----------
  clang-format: [JS] options for arrow functions.

Summary:
clang-format currently always wraps the body of non-empty arrow
functions:

    const x = () => {
      z();
    };

This change implements support for the `AllowShortLambdasOnASingleLine`
style options, controlling the indent style for arrow function bodies
that have one or fewer statements. SLS_All puts all on a single line,
SLS_Inline only arrow functions used in an inline position.

    const x = () => { z(); };

Multi-statement arrow functions continue to be wrapped. Function
expressions (`a = function() {}`) and function/method declarations are
unaffected as well.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73335




More information about the All-commits mailing list