-
Notifications
You must be signed in to change notification settings - Fork 157
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
Differentiate documentation from triple slashes and doc attribute #3209
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -636,6 +636,9 @@ struct Attribute | |
|
||
bool inner_attribute; | ||
|
||
// Only relevant in case of a doc attribute | ||
bool from_comment; | ||
|
||
// TODO: maybe a variable storing whether attr input is parsed or not | ||
|
||
public: | ||
|
@@ -644,9 +647,10 @@ struct Attribute | |
|
||
// Constructor has pointer AttrInput for polymorphism reasons | ||
Attribute (SimplePath path, std::unique_ptr<AttrInput> input, | ||
location_t locus = UNDEF_LOCATION, bool inner_attribute = false) | ||
location_t locus = UNDEF_LOCATION, bool inner_attribute = false, | ||
bool from_comment = false) | ||
Comment on lines
+650
to
+651
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. I'm not a big fan of the two booleans here. I think it would be nice to improve it with two enums |
||
: path (std::move (path)), attr_input (std::move (input)), locus (locus), | ||
inner_attribute (inner_attribute) | ||
inner_attribute (inner_attribute), from_comment (from_comment) | ||
{} | ||
|
||
bool is_derive () const; | ||
|
@@ -681,6 +685,8 @@ struct Attribute | |
// Returns whether the attribute is considered an "empty" attribute. | ||
bool is_empty () const { return attr_input == nullptr && path.is_empty (); } | ||
|
||
bool is_from_comment () { return from_comment; } | ||
|
||
location_t get_locus () const { return locus; } | ||
|
||
AttrInput &get_attr_input () const { return *attr_input; } | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -144,8 +144,10 @@ enum PrimitiveCoreType | |||||||||
/* Macros */ \ | ||||||||||
RS_TOKEN (DOLLAR_SIGN, "$") \ | ||||||||||
/* Doc Comments */ \ | ||||||||||
RS_TOKEN (INNER_DOC_COMMENT, "#![doc]") \ | ||||||||||
RS_TOKEN (OUTER_DOC_COMMENT, "#[doc]") \ | ||||||||||
RS_TOKEN (INNER_DOC_COMMENT, "/**!") \ | ||||||||||
RS_TOKEN (OUTER_DOC_COMMENT, "/**") \ | ||||||||||
Comment on lines
+147
to
+148
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.
Suggested change
|
||||||||||
RS_TOKEN (DOC_COMMENT_END, "*/") \ | ||||||||||
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. I think this isn't needed |
||||||||||
RS_TOKEN (DOC_STRING_LITERAL, "string") \ | ||||||||||
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 is this token for? |
||||||||||
RS_TOKEN_KEYWORD_2015 (ABSTRACT, "abstract") /* unused */ \ | ||||||||||
RS_TOKEN_KEYWORD_2015 (AS, "as") \ | ||||||||||
RS_TOKEN_KEYWORD_2018 (ASYNC, "async") /* unused */ \ | ||||||||||
|
@@ -396,6 +398,11 @@ class Token | |||||||||
return TokenPtr (new Token (OUTER_DOC_COMMENT, locus, std::move (str))); | ||||||||||
} | ||||||||||
|
||||||||||
static TokenPtr make_doc_string_literal (location_t locus, std::string &&str) | ||||||||||
{ | ||||||||||
return TokenPtr (new Token (DOC_STRING_LITERAL, locus, std::move (str))); | ||||||||||
} | ||||||||||
|
||||||||||
// Makes and returns a new TokenPtr of type LIFETIME. | ||||||||||
static TokenPtr make_lifetime (location_t locus, std::string &&str) | ||||||||||
{ | ||||||||||
|
@@ -458,6 +465,7 @@ return *str; | |||||||||
case BYTE_CHAR_LITERAL: | ||||||||||
case BYTE_STRING_LITERAL: | ||||||||||
case RAW_STRING_LITERAL: | ||||||||||
case DOC_STRING_LITERAL: | ||||||||||
return true; | ||||||||||
default: | ||||||||||
return false; | ||||||||||
|
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.