-
Notifications
You must be signed in to change notification settings - Fork 9
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
Redone work on adding IndexUnit (Tests and Travis job passed) #2
Conversation
- created IndexUnit class that contains only field List<CompilationUnit> - changed java.jj file to read the stubfiles and generate the IndexUnit object - created JavaParser.class parseIndex and parseResourceIndex that are the copy of the parse and parseResource respectively with the difference in the return type (IndexUnit vs CompilationUnit).
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.
This design is much better! I have a few comments.
@@ -42,7 +43,6 @@ | |||
import java.io.*; | |||
import java.nio.charset.Charset; | |||
import java.nio.file.Path; | |||
import java.util.TreeSet; |
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.
I would not remove this line (even though it wasn't used in the original file).
The reason is that doing so increases the size of the diff and increases the possibility for merge conflicts in the future.
@@ -295,6 +295,148 @@ public static CompilationUnit parse(String code) { | |||
return simplifiedParse(COMPILATION_UNIT, provider(code)); | |||
} | |||
|
|||
public static IndexUnit parseIndexUnit(final InputStream in, Charset encoding) { |
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.
Please write a Javadoc comment for every method and field.
* Note: Uses UTF-8 encoding | ||
* | ||
* @param path path to a resource containing Java source code. As resource is accessed through a class loader, a | ||
* leading "/" is not allowed in pathToResource |
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.
Minor: add period at end of sentence.
|
||
/** | ||
* Parses the Java code contained in a resource and returns a | ||
* {@link IndexUnit} that represents it.<br> |
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.
The trailing <br>
is not necessary.
* {@link IndexUnit} that represents it.<br> | ||
* | ||
* @param path path to a resource containing Java source code. As resource is accessed through a class loader, a | ||
* leading "/" is not allowed in pathToResource |
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.
Missing period. (The same comment applies a few other places below.)
@@ -672,6 +672,74 @@ TOKEN : | |||
/* | |||
* Program structuring syntax follows. | |||
*/ | |||
IndexUnit IndexUnit(): |
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.
Since this is an addition and not part of the Java language, there should be a comment. The comment should also point at a user-visible description of what may appear in an IndexUnit.
@@ -672,6 +672,74 @@ TOKEN : | |||
/* | |||
* Program structuring syntax follows. | |||
*/ | |||
IndexUnit IndexUnit(): |
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 is the reason for the name IndexUnit? I would have expected a name that uses the word Stub, which is what is used in the Checker Framework documentation.
NodeList<CompilationUnit> compilationUnits = emptyList(); | ||
CompilationUnit cu; | ||
|
||
/* Parsing the compilation unit itself */ |
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.
I don't understand this comment.
Maybe you mean that the above two variables are the representation of the object being parsed, and the remaining variables are temporary variables that will be used during parsing. Whether or not my guess is right, please clarify.
) | ||
|
||
[ LOOKAHEAD(PackageDeclaration()) pakage = PackageDeclaration() ] | ||
( |
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.
Why does this repeat the identical text (but with different indentation!) as "A A*" rather than using the "A+" syntax? That is, can you use Kleene Plus here instead of Kleene Star? If not, explain why not.
) | ||
) | ||
{ | ||
cu = new CompilationUnit(range(token_source.getHomeToken(), token()), pakage, imports, types, module); |
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.
This seems to require a correct, complete compilation unit. Is it your plan in the future to relax this restriction so that various parts (such as method bodies) can be omitted? That's fine, but the scope of this particular pull request wasn't clear from the description.
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.
Yes, that is right. I will work on relaxing restrictions later.
Added throwing the RuntimeException instead of returning the null value.
… class that reflects the stub files.
- Added comments of the fields declarations and stub files reading - Added using of A+ syntax instead of A A* syntax
… in ObservableProperties and ModifierVisitor
…throw a RuntimeException with a message that the method is not implemented
…hanges done in javaparser project.
…ber of changes done in javaparser project.
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.
Looks good overall. Thanks! Please address my comments and then merge.
@@ -43,7 +44,6 @@ | |||
import java.nio.charset.Charset; | |||
import java.nio.file.Path; | |||
import java.util.TreeSet; | |||
|
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.
Please avoid whitespace changes. (Even if they are good, they can lead to merge conflicts.)
/** | ||
* <p> | ||
* This class represents a stub file. The stub file is a Java file, but with the optionally omitted | ||
* information that is not relevant to pluggable type-checking; this makes the stub file smaller |
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.
Add a cross-reference to the full definition of a stub file. (You may need to update that definition as the project proceeds.)
|
||
/** | ||
* <p> | ||
* This class represents a stub file. The stub file is a Java file, but with the optionally omitted |
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.
A stub file isn't just a Java file with some information omitted. It's a concatenation of multiple Java files.
Without this information, "the list of compilation units" below is confusing.
public class StubUnit extends Node { | ||
|
||
/** | ||
* The field represents a list of compilations units. |
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.
The field doesn't represent a list of compilation units; it is a list of compilation units. Make the comment give information beyond the type if possible.
(Typo: "compilations units" should be "compilation unit".)
private StubUnit.Storage storage; | ||
|
||
/** | ||
* The constructor that takes the tokenRange and just pass it to the super method {@link Node}. |
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.
Internal implementation details don't belong in Javadoc. It's better to say what the TokenRange is or represents or how it is used, if possible.
Also, Javadoc should say what the method does, not what it is. Rather than, "the constructor that...", write something like "Constructs a StubUnit from a list of tokens".
* Represents the particular compilation unit components in each iteration of | ||
* reading compilation units from the stub file | ||
*/ | ||
PackageDeclaration pakage = null; |
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 is still inconsistent use of tabs vs. spaces in this file.
(The lines that start with *
aren't properly indented either.)
CompilationUnit cu; | ||
|
||
/* | ||
* Represents the particular compilation unit components in each iteration of |
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 are the "particular" ones?
( LOOKAHEAD(2) ";" )* | ||
( | ||
/* | ||
* Reading the particular compilation unit in the stub file |
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 do you mean by "particular" compilation units? Do you just mean the ones in the file?
Minor (but aids readability): end a sentence with punctuation rather than making the reader guess where sentences end and start.
( | ||
/* | ||
* Reading the particular compilation unit in the stub file | ||
* Number of compilation units could be 1+ |
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.
Not "could be" but "is".
cu = new CompilationUnit(range(token_source.getHomeToken(), token()), pakage, imports, types, module); | ||
compilationUnits.add(cu); | ||
} | ||
) |
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 have made a design choice to remove the *
that appears at this location in CompilationUnit. That affects how a file is split up: you split it up into the largest possible number of CompilationUnits as opposed to the smallest possible number. That's fine, but perhaps worth commenting about.
- Moving reading package declaration (at the begin of the stub file is required); - Reading additional package declarations later in the stub file (not required by the stub file format); - Reading imports (not required by the stub file format); - Constructors and method bodies could be omitted for the stub files; - Number of compilation units could be 1+ according to the stub file structure; - Added comments in java.jj file. Maven test is successful. Tested on the flow.astub file (need to move package declaration to the beginning of the file).
- Reformatted changes done in java.jj file to be consistent; - Added fixes to the comments
What is your plan for merging this pull request? Once a pull request has been reviewed and approved, it's generally best to merge it. Otherwise, if you continue to make changes, then the whole pull request has to be re-reviewed. |
I tried to fix some English errors myself, but I don't seem to have permission to push to your repository. Could you please grant me that permission? |
@mernst, got it. |
Matozoid issue 912 modifier node
Updating with changes from javaparser repository
Maven test and Travis job passed
https://travis-ci.org/Bohdankm22/javaparser/builds/243882845