Skip to content

Feature/folding#22

Open
justinvdk wants to merge 4 commits into
develop/shellfrom
feature/folding
Open

Feature/folding#22
justinvdk wants to merge 4 commits into
develop/shellfrom
feature/folding

Conversation

@justinvdk

Copy link
Copy Markdown

Implements folding for term results (like parsing).

This class already did that, but without telling java

@wouterjsmit wouterjsmit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems fine, some things must be better documented and the common ancestor of the Fold and PrettyPrint functions/results could use a thought.

/**
* Helper to wrap {@link IStrategoTerm#writeAsString}.
*/
private static class Helper implements Appendable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation regarding why this class exists and what it does (it breaks lines on parentheses) is not clear enough. Possibly rename to better reflect what it does in the class name?

*
* @return {@link PrettyPrintFunction} - The pretty print function.
*/
public FailableFunction<ISpoofaxTermResult<?>, PrintResult, IResult> pPrettyPrintFunction() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't go with the p prefix. It is used by other functions to denote whether they were chained to analyze or parse, but in this case it is evident.

Possibly even consider prefixing with term to denote that it requires an ISpoofaxTermResult<?>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

/**
* Helper to wrap {@link IStrategoTerm#writeAsString}.
*/
private static class Helper implements Appendable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as with the Helper in the FoldFunction, this could be better explained.

* The wrapped {@link ISpoofaxParseUnit}.
* @param regions
* The {@link IRegionStyle}s in terms of {@link IStrategoTerm}s.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad copy-paste

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

/**
* Represents a result that is a term and foldable regions.
*/
public class FoldResult implements IResult {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not maybe inherit from an ISpoofaxTermResult, seeing that this result also has a term?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

/**
* A result that represents output that is human readable.
*/
public class PrintResult implements IResult {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this class seems to depend on the Fold regions, would it not be wise to make a common ancestor/somehow denote this? They both have a List<ISourceRegion> which is meant to be the same fold regions, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result would then be a common ancestor with empty children to let Guice differentiate, or do the binding more explicit. Treating them as separate yields a clearer structure at the cost of minimal (seemingly) redundancy.

* @return {@link FailOrSuccessResult} - A {@link PrintResult} containing a human readable
* text plus fold regions, or a failed result.
*/
FailOrSuccessResult<PrintResult, IResult> print(ISpoofaxTermResult<?> input);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also provides folding right? Maybe foldAndPrint or simply fold is more appropriate (result is a textual (pretty-printed) representation of a folding).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that a printresult is (potentially) foldable and the print logic understands the foldregions. Calling this function merely asks to print a given input, thats why its just called print. I can't think of cases in which this method will be used without the result containing foldRegions so I renaming it is ok by me.

@justinvdk justinvdk force-pushed the feature/folding branch 3 times, most recently from e8cddc2 to 300b461 Compare July 5, 2017 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants