Skip to content
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

Comments & Indentation bugfix #89

Conversation

jvcoutinho
Copy link
Collaborator

@jvcoutinho jvcoutinho commented Jul 24, 2019

This PR fixes #42.

Comments

  • Fixed a bug where orphan comments were typically lost after a merge.
    • The start and final tokens of a class declaration body ("{" and "}" brackets, respectively), are now both FSTTerminals. This allows the orphan comments of a class to be addressed as prefixes (and we can indent them properly).
  • Fixed a bug where renaming handlers did not take account prefixes.
  • Added more tests for comments.
  • Prefix merge avoids two-way merges to prevent false positives, performing fast-forward merges instead.

Indentation

  • The program does preserve the indentation now, including tabs/spaces difference and with conflict scenarios.
  • Created a new PrettyPrinter (with the feeling of Suggestion: extend FST classes to S3M classes #92). The generator automatically changes the inheritance of the generated pretty-printer to this one.
  • New feature (debatable): if left and right add the exact same comment but at different lines, we don't textual merge them (this would lead to a duplicate at the end). Instead, we choose the contribution with more blank lines after the comment to fast-forward.

@jvcoutinho
Copy link
Collaborator Author

O erro do Travis, aparentemente, é um bug do lado deles.

@pauloborba
Copy link
Collaborator

@guilhermejccavalcanti have you checked this? is there a better approach for handling comments at the end of class declarations?

@guilhermejccavalcanti
Copy link
Owner

I couldn't think of a better solution.

@jvcoutinho jvcoutinho force-pushed the comments-indentation-bugfix branch from d6f58bc to 2dc106d Compare August 14, 2019 03:33
if (lines.get(i).contains("extends AbstractFSTPrintVisitor")) {
lines.set(i, "public class SimplePrintVisitor extends S3MPrettyPrinter {");
lines.set(i - 1, "import br.ufpe.cin.printers.S3MPrettyPrinter;");
for (int j = 1; j <= 6; j++) {

Choose a reason for hiding this comment

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

até entendo a necessidade da gambiarra, mas esse loop, com essas constantes hardcoded fica complicado de entender. eheheh qual o significado?

Choose a reason for hiding this comment

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

@jvcoutinho falta o comentário ainda?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@guilhermejccavalcanti pronto, tinha esquecido de dar push

@jvcoutinho
Copy link
Collaborator Author

jvcoutinho commented Aug 20, 2019 via email

@guilhermejccavalcanti
Copy link
Owner

guilhermejccavalcanti commented Aug 20, 2019 via email

@pauloborba
Copy link
Collaborator

pauloborba commented Aug 20, 2019 via email

@guilhermejccavalcanti guilhermejccavalcanti merged commit f292112 into guilhermejccavalcanti:master Aug 28, 2019
@jvcoutinho jvcoutinho deleted the comments-indentation-bugfix branch December 3, 2019 00:54
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.

Indentation and Comments inconsistent with the original code
3 participants