Navigation Menu

Skip to content
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

[SR-6964] Syntax highlighting for #warning and #error #49512

Closed
johnfairh opened this issue Feb 9, 2018 · 15 comments
Closed

[SR-6964] Syntax highlighting for #warning and #error #49512

johnfairh opened this issue Feb 9, 2018 · 15 comments
Assignees

Comments

@johnfairh
Copy link
Contributor

Previous ID SR-6964
Radar None
Original Reporter @johnfairh
Type Improvement
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Improvement
Assignee @johnfairh
Priority Medium

md5: 456efda40cce6bb8efb33fedcf9fdbfb

Issue Description:

Right now #error/#warning come out as pinkish (in default Xcode colors) rather than the brownish used for #if etc – see 'current' screenshot.

Is this intentional? Otherwise it might look better to classify them as buildconfig.keyword the same as #if etc, along the same lines as Xcode for ObjC & the Swift vim support – see 'proposed' screenshot.

@harlanhaskins what do you think? I have a patch if you want it.

@belkadan
Copy link
Contributor

belkadan commented Feb 9, 2018

What does #sourceLocation do?

@johnfairh
Copy link
Contributor Author

Ah right, #sourceLocation is pink like the expressiony pound-keywords. Maybe the idea is brown just for control flow, then.

@belkadan
Copy link
Contributor

belkadan commented Feb 9, 2018

@akyrtzi, thoughts?

@akyrtzi
Copy link
Member

akyrtzi commented Feb 10, 2018

Making it brownish will match how Xcode shows #error/#warning in C-family languages, but I'd recommend to classify those separately (maybe 'pound.diagnostic'), and leave it to the client to decide how to color. Even though that means Xcode will need an update to color it properly.

@johnfairh
Copy link
Contributor Author

Or 'builddirective.keyword' to include #sourceLocation and any future pound-statements?

@belkadan
Copy link
Contributor

Nitpick: "builddirective" isn't a good name. The "build" in "buildconfig" refers to "checking the configuration of the thing we're building". (We also ditched that name in Swift 3 because Xcode has its own feature called "build configurations", but SourceKit requests are supposed to be stable-ish.)

@akyrtzi
Copy link
Member

akyrtzi commented Feb 12, 2018

How about 'pound.keyword' ?

@johnfairh
Copy link
Contributor Author

OK!

@johnfairh
Copy link
Contributor Author

#14742

Working through that I went with 'poundstmt.keyword' because 'pound.keyword' felt too close to "keywords that begin with pound" (including #line eg.) which is not meant here.

@belkadan
Copy link
Contributor

Hm. It's not a statement, though. (I may be being too nitpicky but "statements" can appear in certain places in the grammar.) Maybe going back to "directive"?

@johnfairh
Copy link
Contributor Author

It is tricky - maybe try to read as 'pound keyword that introduces a statement'?

(The grammar calls these things 'compiler control statements' – I appreciate that refers to the pound-keyword and its arguments – as a production under 'statement'.)

@belkadan
Copy link
Contributor

That grammar is incorrect. They're much closer to declarations, especially in Swift 4.1 and later. But even then they can appear where neither a statement nor a declaration can appear.

@belkadan
Copy link
Contributor

(I admit that appealing to "the grammar in my head" or "the grammar defined by the current implementation of the parser" is not a great argument. But I'd rather not encode a misleading name forever.)

@johnfairh
Copy link
Contributor Author

No it's a good note, thanks, I'm sure the documented grammar will catch up with reality. So, catching up with a previous comment of yours now, I see 'directive' could work as a term that doesn't imply anything else. Will change to that unless further ideas.

@johnfairh
Copy link
Contributor Author

Supported by Xcode in beta 5.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants