Skip to content

[SR-7904] Add source filenames in the output of -dump-ast #17219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2018

Conversation

fedetrim
Copy link
Contributor

Text by Vinicius Vendramini in SR-7904:

The Swift compiler's -dump-ast functionality prints an output that doesn't include the file names, which can make it impossible to distinguish between different files.
For instance, when compiling two files a.swift and b.swift, both containing the code "private func foo() { }", with the command "$ swiftc b.swift a.swift -dump-ast", we get this output:

(source_file
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))
(source_file
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))

It would be very useful if this information included the file name (or, even better, the file path). Something like this:

(source_file "/path/to/a.swift"
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))
(source_file "/path/to/b.swift"
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))

Resolves SR-7904.

@beccadax
Copy link
Contributor

This looks like a great start! It looks like it doesn't quote the path, though; I think that would be better, since other places where we put an arbitrary string into the AST usually quote them.

@fedetrim
Copy link
Contributor Author

@brentdax you are right! Fixed that, and also removed my FileColor in favour of the already existing LocationColor. Let me know if that's OK or another color is needed/wanted here. Thanks!

@jckarter
Copy link
Contributor

@swift-ci Please smoke test

@fedetrim
Copy link
Contributor Author

@jckarter @brentdax hey guys! I see the smoke tests passed successfully, is there anything else I can do to improve this PR?

@jckarter jckarter merged commit d17b767 into swiftlang:master Jun 21, 2018
@jckarter
Copy link
Contributor

Looks good, thanks for reminding me to commit it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants