SwiftFiddle / swift-ast-explorer

AST visualizer for Swift source code

Home Page:http://swift-ast-explorer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for effective access control levels

SimplyDanny opened this issue · comments

The rules for access control levels (ACL) that take effect in Swift (how the compiler determines them) are not always obvious. I'm thinking about questions like:

  • What is the default ACL of a declaration defined in a type or extension?
  • What is the ACL of nested types and their children?
  • Which declarations can be access from other declarations inside of the same file?
  • What can be seen when importing the module that contains the file at hand?
  • ...

I think that effective ACLs can be computed on a syntax-level only. There is no knowledge of compilation options or resolved types needed.

Thinking about visualization: There could be another tab in the editor on the right for ACLs. And then in a drop-down menu one can select "Access from the same file", "Access from the same module" and "Access as an importer" which would result in different highlighting in the editor. In fact, the accessible declaration would be highlighted. On hover, one could see the effective ACL of a declaration. And perhaps also highlight other declarations that are accessible from the current scope (where the cursor is placed).

These are just ideas. There might be better ones ...

What is the general impression about such a feature?