-
Notifications
You must be signed in to change notification settings - Fork 733
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
Code review request #42
Comments
Original comment posted by alexeagle@google.com on 2012-09-11 at 09:06 PM Shuffling to Eddie since I don't have time to take a careful look. Owner: eaftan@google.com |
Original comment posted by sjnickerson@google.com on 2012-09-12 at 07:03 AM Thanks for taking a look, Alex. I share your concern, but looking at the object in the AST, it simply doesn't have the information needed. The JCLiteral object just knows its position in the source file, and its value as a long. It doesn't record know whether a suffix is present, let alone whether it's an 'L' or 'l'. It also don't record whether it's encoded as hex, or octal, or decimal, or whether there are underscores present (for Java 7) and whether the hex elements (a-f and the 'x' in 0x...) of it are upper or lower case. Unfortunately we need to somehow extract this from the source. My belief (based on little evidence at the moment) is that the source code string is already probably cached - I assume this is why sourceFile.getCharContent() can return null. If this is indeed the case, would your objection go away? |
Original comment posted by sjnickerson@google.com on 2012-09-12 at 07:36 AM I've tried this out by running "mvn test". The call SourceFile#getCharContent() is actually RegularFileObject#getCharContent(), which includes this at the top of the method: CharBuffer cb = fileManager.getCachedContent(this); Based on stepping through the code, this returns a non-null reference containing the cached source file data. This seems to indicate to me that this matcher isn't going to have to keep re-reading the source file. |
Original comment posted by alexeagle@google.com on 2012-09-12 at 06:10 PM Yeah if the source is already cached, that's great. I imagined it might be, since the API gives you the CharSequence directly. |
Original comment posted by eaftan@google.com on 2012-09-12 at 09:57 PM FYI, JLS section 3.10.1 says of long literals, "The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one)." So I think we're justified in making this a compile error as long as it doesn't kill performance. |
Original comment posted by eaftan@google.com on 2012-09-13 at 12:39 AM (No comment entered for this change.) Status: Fixed |
Original issue created by sjnickerson@google.com on 2012-09-11 at 11:21 AM
Branch name: longliteral
Purpose of code changes on this branch: Add checker for long literals ending with lower case ell, e.g. 123432l rather than 123432L. See #23
After the review, I'll merge this branch into: /master
The text was updated successfully, but these errors were encountered: