2

Netbeans considers for await syntax to be invalid. The error hint indicates: "Expected ( but found await". Source > Format will not work as expected while the for await remains.

Is there a way to update the existing syntax checker for .js files to mark for await as valid syntax, so that the code formatter will work correctly again?

I tried to review FAQs on the official site for Netbeans. All the relevant questions lead to page not found dead ends.

I tried to go to Tools > Options > Miscellaneous > Files to edit the associated file config for js which defaults to text/karmaconf+javascript. It's possible to change the file type, but not to edit the existing one. I searched the netbeans program files path for the config file to update it manually, but I don't quite know how to find it.

skomisa
  • 16,436
  • 7
  • 61
  • 102
OXiGEN
  • 2,041
  • 25
  • 19
  • I found a workaround when the `for of` loop contains an `await` inside the closure that will run on each iteration. The `await` outside the closure is no longer needed, and Netbeans formatting works as expected again. Not a solution when some iterations do not have an `await`, but all use cases for me do. – OXiGEN Mar 13 '23 at 04:49

1 Answers1

2

I can reproduce your issue in NetBeans 16, and it has already been bug reported. See NetBeans Bug Report #4757 JavaScript to support "for await of" #4757.

You could opt to filter out the parsing error:

forAwait

However, that approach would probably cause more problems that it would solve. While it would make that "Expected ( but found await" message go away, at a minimum it would also impact the parsing of the entire file, and would not impact formatting at all. (I realize that was not part of your question, and mention it only for completeness.)

Apart from that, all you can really do is update the bug report to voice your concern in the hope that it increases the priority of fixing the bug.

Unfortunately I don't see any way to resolve the issue through configuration changes in NetBeans.

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • Thanks. I managed to get past the formatting issue (which may have been a closure error on my part). I think I got stuck remembering when older versions of Netbeans messed up formatting due to `??=` operators. Still annoying to see valid syntax flagged with red bars on the side. – OXiGEN Feb 06 '23 at 05:44
  • @OXiGEN FWIW, I bug reported a somewhat similar issue with [CSS enhancements not being recognized in NetBeans](https://issues.apache.org/jira/browse/NETBEANS-445), and it took two and a half years to get a fix. That said, one possible way to get a fairly speedy resolution for this issue is for you to consider writing the code fix yourself! See [Contributing code](https://netbeans.apache.org/participate/index.html#_contributing_code). – skomisa Feb 06 '23 at 06:36