megaboich / js-map-parser

Extension for Visual Studio to improve JS support
85 stars 19 forks source link

Parser finds errors that aren't errors #1

Closed WrayKS1 closed 9 years ago

WrayKS1 commented 9 years ago

For MVC cshtml files the following is valid code: @:<script> @:$(function () { @:var myvar = "x"; etc... @:}); @:</script>

Unfortunately to the parser this is an error as it does not recognize the in-line syntax @:. The only workaround for me is to disable parsing in cshtml files. I have not checked whether <text></text> inline syntax works, but it might. Changing thousands of lines of code to this is not an option anyway.

Hmm looks like disabling cshtml is not an option either. Even when deleted from both config items, it still parses them and shows an error at the top of the file, effectively ignoring the list. (VS restarted)

megaboich commented 9 years ago

Hi WrayKS1,

Thanks for the report. Indeed you have found interesting issue. In general I would not recommend to put any significant amounts of JavaScript to cshtml files. Better to move them to .js files.

Currently plugin has a little weak logic to process Razor syntax, and it is of course can not provide all syntax support. So, for you it is better to disable processing of cshtml files in the settings. BUT, currently if you remove "cshtml" from list of matched extensions it would not help because of a bug. You should also remove "html" from that list. Yes, it currently just check if your full file name ends with some of extensions in the list, and "html" is there. That is why it tries to parse it.

I'll fix that in next release.

megaboich commented 9 years ago

Fixed in 4.0.2 release. Available here: https://github.com/megaboich/jsparser/releases/tag/4.0.2