[fidl-lsp] Resolve relative fidl_project.json paths

fidl_project.json, generated by //build/fidl:gen_fidl_project in
fuchsia.git, now uses paths relative to the build directory. For
example, "../../sdk/fidl/..." for source files and "fidling/gen/..." for
JSON IR.  The language server treated these paths as absolute, so it
resolved them against its own working directory, failed to load any
JSON IR, and go-to-definition, hover, and references returned nothing.

Resolve relative paths in LoadFidlProject against the directory
containing fidl_project.json, so the rest of the server keeps working
with absolute paths. Absolute paths are left unchanged.

Add github.com/google/go-cmp to compare the loaded result in the new
test. v0.6.0 is the newest version compatible with this module's
go 1.14 directive.

Test: go test -run 'TestLoadFidlProject|TestFindDeps' ./analysis/
Test: Ran the patched server against a core.x64 build's unmodified
fidl_project.json; go-to-definition now resolves symbols in the same
library and in dependencies.

Change-Id: I59b87ccc4070853f69bb1c1e883351b7bb515ceb
Reviewed-on: https://fuchsia-review.googlesource.com/c/fidl-misc/+/1901917
Reviewed-by: Ian McKellar <ianloic@google.com>
3 files changed
tree: ffb8f0534a9bde2986cd42ce46bf7d123396c6b2
  1. fidl-lsp/
  2. fidldev/
  3. fidlviz/
  4. mu-fidl/
  5. vscode-language-fidl/
  6. .gitignore
  7. .vscodeignore
  8. AUTHORS
  9. CONTRIBUTING.md
  10. LICENSE
  11. PATENTS
  12. README.md
README.md

Fuchsia Open Source Template Repository

This repository is a template that we will use when creating new open source repositories for Fuchsia.