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

Dangling comments are not printed #13

Closed
dangmai opened this issue Jan 18, 2019 · 6 comments
Closed

Dangling comments are not printed #13

dangmai opened this issue Jan 18, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@dangmai
Copy link
Owner

dangmai commented Jan 18, 2019

For example:

class Comments {
  // Dangling Comment
}

will be turned to:

class Comments {}
@dangmai dangmai added the bug Something isn't working label Jan 18, 2019
@dangmai dangmai self-assigned this Jan 18, 2019
@dangmai
Copy link
Owner Author

dangmai commented Mar 30, 2019

Partially fixed in 5ab40b6

The only exception (that I'm aware of) is in a Trigger Declaration. Somehow jorje decides that a Trigger Declaration starts and ends with the word trigger, which is messing up the algorithm that attaches comments to nodes.

@dangmai
Copy link
Owner Author

dangmai commented Mar 30, 2019

@ntotten @vazexqi

I think I need help from a Salesforce dev here for this issue. The problem is when parsing an empty trigger, jorje does not give me the correct startIndex and endIndex of the trigger node. For example:

trigger myAccountTrigger on Account(after insert) {
  // Inline Comments

  /* Block Comments */
}

jorje gives the following location for the TriggerDeclUnit:

startIndex = 0
endIndex = 7
line = 1
column = 1

Which is not enough information for me to attach comments to the correct nodes in the AST (other declarations like ClassDecl or InterfaceDecl do not have this issue). I can't think of a way to handle this, except for changing the behavior of jorje somehow, which is why I'm reaching out to you guys.

Thanks in advance!

@vazexqi
Copy link

vazexqi commented Mar 31, 2019

The only exception (that I'm aware of) is in a Trigger Declaration. Somehow jorje decides that a Trigger Declaration starts and ends with the word trigger, which is messing up the algorithm that attaches comments to nodes.

@dangmai - OK. I will ping the team about this and have them take a look. Does this only happen on triggers? Does it work as you expect on classes that you have tested on?

@dangmai
Copy link
Owner Author

dangmai commented Mar 31, 2019

@vazexqi thank you Nick, I really appreciate it! No other declaration types have this problem as far as I'm aware. ClassDecl, InterfaceDecl, EnumDecl and BlockStmnt are the main ones that I use to attach dangling comments, and they all report the correct start and end indices for their entire blocks.

@praksb
Copy link

praksb commented May 16, 2019

@dangmai I just released a fix for this issue. Checkout: forcedotcom/salesforcedx-vscode@b8e6d2f

@dangmai
Copy link
Owner Author

dangmai commented May 16, 2019

Awesome, thanks @praksb! I'll update the bundled jorje version to include the fix!

dangmai pushed a commit that referenced this issue Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants