-
Notifications
You must be signed in to change notification settings - Fork 59
Tokenize punctuation (and generics) #22
Conversation
Fixes #19
Looks great, except the square brackets aren't tokenized everywhere. Maybe that's what you mean with This is my (quick) test case: public class MyClass {
public static void main(String[] args) {
String[] array;
HashMap<Integer,String> map = new HashMap<>();
boolean[] list = new boolean[10];
list[i] = (sum == n ? true : false);
}
} Brackets on line 3 aren't scoped: But on line 5 they are: I also noticed bugs on lines 7 and 9 while typing this, i'll open new issues for that. |
Yeah, that's basically what I was talking about. Though it looks like they sometimes get tokenized, so I'll try to fix that :). |
Just a heads up, this no longer merges now that #21 has been merged. |
I'm not sure about that pattern. I'm guessing it tries to find variable names in bulk, so this would pass |
Thanks for taking the time to work on this @50Wliu |
Fixes #23
# Conflicts: # spec/java-spec.coffee
@@ -694,20 +724,7 @@ | |||
'object-types-inherited': | |||
'patterns': [ | |||
{ | |||
'begin': '\\b((?:[a-z]\\w*\\.)*[A-Z]+\\w*)<' | |||
'end': '>|[^\\w\\s,<]' | |||
'name': 'entity.other.inherited-class.java' |
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.
Unfortunately I couldn't find a way to keep this name
with the new generics
include. @kevinsawicki do you know if this should be possible, or was it intentionally not allowed?
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.
do you know if this should be possible, or was it intentionally not allowed?
At first glance, it does appear this would have to be removed to get the new generics patterns working. Nothing jumps out to my as to why this scope would be helpful so I think it is okay to remove it.
Also correct the spelling of separator...
The latest commit a67ef17 changes all commas to be |
Just realized that this doesn't tokenize the comma in all scenarios yet, such as |
Object types weren't getting matched in certain places (eg return types) because of a change in 1bf118e Fix all primitive types always getting matched as arrays
@chbk Fixed, fixed, and fixed 😄. Your Same thing with |
When in doubt, keep fixing. |
@chbk just wanted to ping you in case you didn't see my last comment and commit 😉. |
Sorry I didn't get back to you, your last commit works fine 👍 |
I got back to this and found 2 other bugs: package com.apple.quicktime.v2; // Periods aren't scoped class Test {
public String[][] return2DStringArray() { // Brackets
String[][] array = new String[2][2];
return array;
}
public int[][] return2DintArray() { // Brackets
int[][] array = new int[2][2];
return array;
}
} |
I think I can do a quick-fix for the brackets but the real underlying issue is #24 (the array regex is really broken right now). |
Necessary to highlight periods correctly
Apparently I was wrong...multidimensional arrays turned out to be a lot easier than expected to implement. Think there's anything else to tackle @chbk? This is slowly turning into a full-blown rewrite of the entire grammar 😆. |
At least, I'm pretty sure it's not needed since `#code` should match it
All these changes are starting to add up indeed! I don't see anything else, besides #24 and perhaps these minor enhancements:
|
`instanceof` is now `keyword.operator.instanceof.java` Fixed a few implementation bugs in the `package` invalid character regexes
@chbk hopefully this will be the last test! |
'match': '\\s' | ||
'name': 'invalid.illegal.character_not_allowed_here.java' | ||
'match': '\\*' | ||
'name': 'punctuation.wildcard.java' |
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.
@MaximSokolov Do you think this naming is ok?
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.
How about wrapping brackets with {
'begin': '(\\[)'
'beginCaptures':
'0':
'name': 'meta.brace.square.scope-is-for-back-capability.java'
'1':
'name': 'punctuation.bracket.square.java'
# ...
} This allows to use |
@@ -448,10 +492,56 @@ | |||
'captures': | |||
'1': | |||
'name': 'keyword.operator.dereference.java' |
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.
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.
What about punctuation.separator.deference
? Or are we going with labeling what the actual character is now?
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.
punctuation.separator.accessor
maybe?
`meta.brace` is now `punctuation.bracket` All brackets now contain the type of bracket in their scope `keyword.other.dereference` is now `punctuation.separator.period`
I think this is ready for review now. |
🚢ing to get some exposure. I'm fairly confident this works as expected, and there's extensive spec coverage. |
This PR tokenizes a lot of the missing Java punctuation, such as parentheses, square and curly brackets, angle brackets and commas (for generics), etc.
Fixes #19
Fixes #23
Fixes #29