-
Notifications
You must be signed in to change notification settings - Fork 1.4k
syntax/c: highlight the header name in #include as a string, not a type #4236
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
base: master
Are you sure you want to change the base?
Changes from all commits
72caeb5
da80c69
8ae90fe
555409f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ rules: | |
| - statement: "\\b(nonatomic|atomic|readonly|readwrite|strong|weak|assign)\\b" | ||
| - statement: "@(encode|end|interface|implementation|class|selector|protocol|synchronized|try|catch|finally|property|optional|required|import|autoreleasepool)" | ||
|
|
||
| - preproc: "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$" | ||
| - preproc: "^[[:space:]]*#[[:space:]]*(define|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$" | ||
| - preproc: "__[A-Z0-9_]*__" | ||
|
|
||
| - special: "^[[:space:]]*[#|@][[:space:]]*(import|include)[[:space:]]*[\"|<].*\\/?[>|\"][[:space:]]*$" | ||
|
|
@@ -33,6 +33,15 @@ rules: | |
| - constant: "\\bk[[:alnum]]*\\b" | ||
| - constant.string: "'.'" | ||
|
|
||
| # #include lines are a region so that the header name (e.g. <float.h>) | ||
| # is not matched by the type rules above | ||
| - special: | ||
| start: "^[[:space:]]*#[[:space:]]*(include(_next)?|import)\\b" | ||
| end: "$" | ||
| rules: | ||
| - constant.string: "<[^>]*>|\"[^\"]*\"" | ||
| - comment: "//.*|/\\*.*?\\*/" | ||
|
Comment on lines
+36
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between this and line 25? Other than line 25 covering
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. With the region in place, line 25 no longer applies to any I diffed objc.yaml with and without line 25 over 22 valid and invalid lines. Only three change: Merging it into the region would be worse: the region would then also take So I think it can simply go. I restored it after the earlier review to keep the output identical for every input. @Andriamanitra, are you OK with removing it? |
||
|
|
||
| - constant.string: | ||
| start: "@\"" | ||
| end: "\"" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You accidentally removed highlighting for
@importhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored it verbatim in 555409f.
@import Foundation;was never affected (the@(...)statement rule covers it), but@import <Foundation/Foundation.h>and@import "X.h"lost highlighting since the region only matches#. The region supersedes that rule for#lines, so it still does its job for@.I also diffed every touched syntax file before/after over a corpus: the only lines that change now are
#include/#importdirectives.