XVincentX / vscode-apielements

VSCode extensions for API Elements (aka: API Blueprint and Swagger)
MIT License
120 stars 15 forks source link

Manage SourceMap lacks #3

Open XVincentX opened 8 years ago

XVincentX commented 8 years ago

Actually the source map reference for a particular symbol is done guessing where the reference could be

      /*
        Unfortunately drafter is missing some required sourcemaps, so as a
        temporaney solution, I have to try to lookup into multiple paths.
      */
      let sourceMap = lodash.get(queryResult, 'attributes.sourceMap',
        lodash.get(queryResult, 'meta.title.attributes.sourceMap',
          lodash.get(queryResult, 'attributes.href.attributes.sourceMap',
            lodash.get(queryResult, 'content[0].attributes.method.attributes.sourceMap')
          )
        )
      );

While this actually kind-of-works, it can miss better sourcemaps developed with future drafter version as well not get all cases.

  1. The idea here would be that, when missing sourcemaps on queried element, a refract-query call should be performed with a 1 limit, and use that as nearest sourcemap
  2. Another idea would be take first AND last sourcemaps object from the childs and compute the block from those ones. Mark them as inferred, eventually.

It would be a great idea to signal this thing to VSCode some how, like "Hey, this is not the precise sourcemap, but this is the nearest I was able to find."

XVincentX commented 8 years ago

This has been partially solved in #4

I still cannot track entire objects, but I do not have to use those horrible fallbacks anymore.

XVincentX commented 8 years ago

Actually this might really need a modification in the parser. Will see about that.