Giter VIP home page Giter VIP logo

Comments (3)

taku0 avatar taku0 commented on June 22, 2024

Our lexer needs to analyze the type of tokens and required to parse both forward and backward, rather than just skipping forward. It also needs to parse various constructs other than types.

Hiding bodies would be useful, but why not just use hs-hide-all or hs-hide-level? Those functions can handle other types of blocks and parenthesis. For example, swift-hide-bodies doesn't hide let definitions in Parser.swift while hs-hide-level handles parenthesized expressions well.

Besides, swift-hide-bodies needs some improvements:

  • swift-skip-type-name doesn't skip those types:

    • Types with attribute: @A B
    • Implicitly unwrapped optional types: Int!
    • Protocol composition types: P & Q
    • Opaque types: some P
    • Explicit existential types: any P
    • Async function types: (Int) async throws -> Int
    • Type names in backticks: `Int`
    • Type names with emoji: 😊
  • swift-hide-bodies mishandles:

    • Bare keyword as an identifier:

      class Foo {
        func `deinit`(f: () -> Void) -> Void {
          f()
        }
      }
      
      let foo = Foo()
      // we can use bare keyword as identifier after dot.
      let x = foo.deinit {
        print("aaa")
      }
    • var in case patterns:

      if case var x: Int=1 {
        print("aaa")
      }

      Note that swift-skip-type-name thinks Int=1 is a type name.

swift-hide-doc-comment-detail seems to be nice to incorporate. I'm not sure how to combine codes under Apache License v2.0 and GPLv3, though I know that Apache License v2.0 is compatible with GPLv3.

Other than that, Apple's swift-mode seems to be less accurate while concise and efficient; it doesn't handle those constructs:

  • Multiline string literals:

      let x = """
        aaa " aaa
        """
      let y = Foo()
  • Extended string literals: #"abc"def"#

  • String interpolations: "aaa \(/* " */ 1) bbb"

  • Regular expressions.

  • Nested multiline comments.

from swift-mode.

dabrahams avatar dabrahams commented on June 22, 2024

from swift-mode.

taku0 avatar taku0 commented on June 22, 2024

hs-hide-all hides too much (the methods and properties of every type); I was unable to make hs-hide-level do anything useful in my Swift file.

C-2 M-x hs-hide-level at the beginning of the Parser.swift will show you outline of the file.

? let definitions don’t ever have bodies in Swift. A body is a block surrounded by braces at the top level of a declaration.

Parser.swift has many let bindings with large expression, that is, functionDecl and followings. To grab the outline of the file, it should be hidden.

from swift-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.