oleg-shilo / codemap.vscode

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

Generic Mapper: a pipe char in the source interferes with the complete mapping #66

Closed gitarian closed 2 years ago

gitarian commented 2 years ago

Hi,

first of all, this is indeed a very, very useful extension. Thanks a lot for publication:-)

\ After setting up the first generic map (which generally works out nicely) I realized that the "|"-symbol somehow generates incomplete results.

source code: function getExpKey($iniFile, $sep="|", $key) {

regex definition: "pattern": "(?<=^function )\\w*\\(.*\\)(?=\\s*\\{)",

result (in tree view): getExpKey($iniFile, $sep=" (additionally, the tree view entry has no icon and is not navigateable)

\ \ From a very brief look at the code I guess it's caused by internal usage of the "|" as a seperator in the mapping logic, like in

mapper_generic.ts, line 129: map = map + extra_line + prefix + lean_content + '|' + String(line) + '|' + icon + '\n';

\ I may find a regex skipping the "|" (I fear it's getting to complicated ...), but it would be much better if the sources can contain any kind of char. ;-)

edits: typos

oleg-shilo commented 2 years ago

Agree. Will have a look

oleg-shilo commented 2 years ago

Done. Fixed in v1.16.3

gitarian commented 2 years ago

Hi Oleg,

thanks for the quick fix. :-)) I especially like the nature of the fix (temp replacement) because it's something of a kind I always think "no, that's too simple". ;-)

..... purchased a 10 bucks item in return.

oleg-shilo commented 2 years ago

Glad we were able to handle it quickly. BTW thank you very much for your support. Much appreciated

gitarian commented 2 years ago

You're welcome! I'm happy either. :-)

I'm currently building my very first VScode extension (of course, for exotic stuff: XYplorer scripting). The easy basics (syntax higlighting, snippets) have been done, now I have started to target the deeper stuff (hovers, go to etc - yet I think I won't do a Language Server ). But I'm still more lurking around typescriptlang than making real progess. ;-)

Nevertheless, CodeMap is already of great help, and actually provides a feature I can put off my list. Maybe I will contribute a dedicated mapper in the future.

Have a nice weekend.

oleg-shilo commented 2 years ago

BTW, you can have a look at my VSCode extension for CS-Script. It is a script engine for C#. I have integrated it with Sublime Text, VSCode and Notepad++. With full support for IntelliSense (auto-completion, find references, Go to definition, etc)

You may find that all the challenges you are going to have been already solved. At least it will give you a jump start. The luxury I did not have :) https://github.com/oleg-shilo/cs-script.vscode

gitarian commented 2 years ago

During debuging my extension I got the following output on the vscode debug console:

SyntaxError: Invalid regular expression: /(/: Unterminated group
    at new RegExp (<anonymous>)
    at String.<anonymous> (${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\utils.js:27:27)
    at ${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\mapper_generic.js:49:55
    at Array.forEach (<anonymous>)
    at ${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\mapper_generic.js:47:38
    at Array.forEach (<anonymous>)
    at Function.generate (${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\mapper_generic.js:32:19)
    at FavoritesTreeProvider.get_map_items [as aggregateItems] (${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\extension.js:82:47)
    at FavoritesTreeProvider.getScriptItems (${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\tree_view.js:88:25)
    at ${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\tree_view.js:56:34
    at new Promise (<anonymous>)
    at FavoritesTreeProvider.getChildren (${pathTo}\VSCode\data\extensions\oleg-shilo.codemap-1.16.3\out\src\tree_view.js:48:16)
    at _.fetchChildrenNodes (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:19383)
    at _.getChildren (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:15769)
    at v.$getChildren (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:11860)
    at i._doInvokeHandler (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13826)
    at i._invokeHandler (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13510)
    at i._receiveRequest (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:12171)
    at i._receiveOneMessage (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:11044)
    at ${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:8947
    at u.invoke (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at ${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:34275
    at u.invoke (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at o._receiveMessage (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:23615)
    at ${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:21149
    at u.invoke (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at v.acceptChunk (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:15865)
    at ${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:14995
    at Socket.P (${pathTo}\VSCode\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:13797)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) {stack: 'SyntaxError: Invalid regular expression: /(/:…Trampoline (node:internal/async_hooks:130:17)', message: 'Invalid regular expression: /(/: Unterminated group'}

The real stack is longer, but I think that doesn't matter. In VSCode "normal" usage I didn't see any problem popped to the UI. Let me know, if I can help any further.

oleg-shilo commented 2 years ago

Can you please provide the mapper and the code that you are mapping? I can have a look.

But... am I right interpreting your feedback as "everything works but there is some error in the debug output"?

gitarian commented 2 years ago

> But... am I right interpreting your feedback as "everything works but there is some error in the debug output"? Yes.

It was just by chance (debugging mode|F5), otherwise I don't see anything pointing to hickups.

But anyway, this is my settings.json entry:

  // --------------------- Extension: CodeMap ------------------------------
  "codemap.xyi": "config:codemap.xys",
  "codemap.xys": [
    {
      "pattern": "(?<=^\")([^-].*)(?=\")",
      "clear": "\"",
      "icon": "script",
      // "icon": "function"
    },
    {
      //"pattern": "(?<=^function )\\w*\\(([, ]*\\$\\w*)*\\)(?=\\s*\\{)",
      "pattern": "(?<=^\\s*function )\\w*\\(.*\\)(?=\\s*\\{)",
      "clear": "(",
      // "icon": "path:D:\\Personal\\Projects\\My\\git_working-copies\\VSCode\\xyscript-vscode\\icons\\green_square.svg",
      "icon": "function"
    },
  ],

No (dedicated) mapper over her, yet. ;-)

oleg-shilo commented 2 years ago

Not sure what it is but my debug console is clean. Basically, I cannot reproduce it.

What is even more interesting is that the method has unconditional top-level try...catch. Meaning that regardless of the possible invalid input the method cannot throw.

Thus I can only explain what you are observing by debugger printing (for whatever reason) the stack of the handled exception.

gitarian commented 2 years ago

I'm not sure either. I just happend to see it once.

Even if it would happen again some day, since I'm new to TypeScript and VSCode extensions I better spend my rare spare time into the basic things of relevance. ;-)

I close this issue now for good. Thanks again. :-)

oleg-shilo commented 2 years ago

Amen to that :)