-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistent Ruby method highlighting (#1523)
Ruby methods might or might be called in C-style creating inconsistent highlighting. This highlights only method definitions and removes the highlighting of C-style-invoked methods.
- Loading branch information
1 parent
2a4758a
commit 7277591
Showing
8 changed files
with
106 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
class Circle | ||
def self.of_diameter(diameter) | ||
new diameter / 2 | ||
end | ||
|
||
def initialize(radius) | ||
@radius = radius | ||
end | ||
|
||
def circumference | ||
Math::PI * radius ** 2 | ||
end | ||
|
||
# Seattle style | ||
def grow_by factor: | ||
@radius = @radius * factor | ||
end | ||
end | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "class"], | ||
["class-name", ["Circle"]], | ||
["keyword", "def"], | ||
["method-definition", [ | ||
["keyword", "self"], | ||
["punctuation", "."], | ||
["function", "of_diameter"] | ||
]], | ||
["punctuation", "("], | ||
"diameter", | ||
["punctuation", ")"], | ||
["keyword", "new"], | ||
["class-name", ["diameter"]], | ||
["operator", "/"], | ||
["number", "2"], | ||
["keyword", "end"], | ||
["keyword", "def"], | ||
["method-definition", [ | ||
["function", "initialize"] | ||
]], | ||
["punctuation", "("], | ||
"radius", | ||
["punctuation", ")"], | ||
["variable", "@radius"], | ||
["operator", "="], | ||
" radius\n ", | ||
["keyword", "end"], | ||
["keyword", "def"], | ||
["method-definition", [ | ||
["function", "circumference"] | ||
]], | ||
["constant", "Math"], | ||
["punctuation", ":"], | ||
["punctuation", ":"], | ||
["constant", "PI"], | ||
["operator", "*"], | ||
" radius ", | ||
["operator", "*"], | ||
["operator", "*"], | ||
["number", "2"], | ||
["keyword", "end"], | ||
["comment", "# Seattle style"], | ||
["keyword", "def"], | ||
["method-definition", [ | ||
["function", "grow_by"] | ||
]], | ||
" factor", | ||
["punctuation", ":"], | ||
["variable", "@radius"], | ||
["operator", "="], | ||
["variable", "@radius"], | ||
["operator", "*"], | ||
" factor\n ", | ||
["keyword", "end"], | ||
["keyword", "end"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks that method definitions are highlighted correctly |