oleg-shilo / codemap.vscode

Code map (syntax tree) of the active document
MIT License
84 stars 28 forks source link

Not working for Javascript file #35

Closed sannamalai176 closed 3 years ago

sannamalai176 commented 4 years ago

Code map is not showing the methods in javascript file.

oleg-shilo commented 4 years ago

Seems like it does.

image

clarkras commented 4 years ago

I have the same problem - the codemap explorer is empty when editing javascript files. image

oleg-shilo commented 4 years ago

It would be great if any of you guys can provide some data that can help to reproduce the problem. Like a file content.

The JS parsing for CodeMap is rather very generic as it does not use and industry grade parsers like Roslyn. Thus addressing any parsing problems without and context is close to impossible.

oleg-shilo commented 4 years ago

One thing that is obvious from your image is the absence of the keyword function. If it is used then parsing works as expected:

image

Though I am a wrong person to comment on JS syntax ambiguities.

CodeMap is using a TS parser so most likely it will miss some cases (e.g. private members). Thus ideally I would like to get the community help here. If someone can contribute a proper JS mapper (either regex based or a dedicated one). I will gladly incorporate it.

This is a very detailed guide for writing custom mappers: https://github.com/oleg-shilo/codemap.vscode/wiki/Adding-custom-mappers

It is actually quite simple