[fidl/lsp] Fix bugs

* update the `analysis.FidlLibrary` type to match the new FIDL JSON IR
  schema introduced in fxrev.dev/452058
* update the third_party/fidlgen library and corresponding copy script
* update the path to the FIDL tools directory

Fixed: 67124
Test: go test -p 1 ./...
Change-Id: I7d3e711511e1d017d4fb328fa7ca58b4fb5068a2
Reviewed-on: https://fuchsia-review.googlesource.com/c/fidl-misc/+/469917
Reviewed-by: Felix Zhu <fcz@google.com>
diff --git a/fidl-lsp/analysis/analyzer.go b/fidl-lsp/analysis/analyzer.go
index 0660a64..7fb1adf 100644
--- a/fidl-lsp/analysis/analyzer.go
+++ b/fidl-lsp/analysis/analyzer.go
@@ -11,7 +11,7 @@
 	"log"
 	"os"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -33,8 +33,8 @@
 // exists (`json`), its deserialized JSON IR (`ir`), and any diagnostics on it.
 // `deps` and `files` are treated as sets.
 type Library struct {
-	name fidlcommon.LibraryName
-	deps map[fidlcommon.LibraryName]bool
+	name fidlgen.LibraryName
+	deps map[fidlgen.LibraryName]bool
 	// This library's constituent files in the form of absolute paths
 	files   map[string]bool
 	json    string
@@ -66,7 +66,7 @@
 
 	// A map from library name to the corresponding tmp file used for their JSON
 	// IR.
-	inputFilesJSON map[fidlcommon.LibraryName]string
+	inputFilesJSON map[fidlgen.LibraryName]string
 }
 
 // NewAnalyzer returns an Analyzer initialized with the set of CompiledLibraries
@@ -76,7 +76,7 @@
 		cfg:            cfg,
 		libs:           []*Library{},
 		inputFilesFIDL: make(map[state.FileID]string),
-		inputFilesJSON: make(map[fidlcommon.LibraryName]string),
+		inputFilesJSON: make(map[fidlgen.LibraryName]string),
 	}
 	return a
 }
@@ -91,7 +91,7 @@
 	// importing a new set.
 
 	for _, compiledLib := range compiledLibraries {
-		name, err := fidlcommon.ReadLibraryName(compiledLib.Name)
+		name, err := fidlgen.ReadLibraryName(compiledLib.Name)
 		if err != nil {
 			log.Printf("could not import compiled library `%s`: %s\n", compiledLib.Name, err)
 			continue
@@ -111,7 +111,7 @@
 		if !alreadyImported {
 			lib = &Library{
 				name:  name,
-				deps:  make(map[fidlcommon.LibraryName]bool, len(compiledLib.Deps)),
+				deps:  make(map[fidlgen.LibraryName]bool, len(compiledLib.Deps)),
 				files: make(map[string]bool, len(compiledLib.Files)),
 				json:  compiledLib.JSON,
 			}
@@ -124,7 +124,7 @@
 			lib.json = compiledLib.JSON
 		}
 		for _, dep := range compiledLib.Deps {
-			lib.deps[fidlcommon.MustReadLibraryName(dep)] = true
+			lib.deps[fidlgen.MustReadLibraryName(dep)] = true
 		}
 		for _, file := range compiledLib.Files {
 			// If the file is already included as a replaced tmp input file,
@@ -165,7 +165,7 @@
 // Ideally, everywhere getLibrary is called should instead use the
 // (*Analyzer).getLibraryWithFile method, since this is guaranteed to be unique.
 // Calls to getLibrary should include a comment explaining why it's necessary.
-func (a *Analyzer) getLibrary(name fidlcommon.LibraryName) (*Library, bool) {
+func (a *Analyzer) getLibrary(name fidlgen.LibraryName) (*Library, bool) {
 	for _, lib := range a.libs {
 		if lib.name == name {
 			return lib, true
@@ -180,7 +180,7 @@
 // This allows a more precise search than getLibrary, since library name + file
 // path together is guaranteed to be unique (a file only belongs to one FIDL
 // library).
-func (a *Analyzer) getLibraryWithFile(name fidlcommon.LibraryName, path state.FileID) (*Library, bool) {
+func (a *Analyzer) getLibraryWithFile(name fidlgen.LibraryName, path state.FileID) (*Library, bool) {
 	// If there is a corresponding temporary input file used by the Analyzer,
 	// use that to lookup the library in a.libs.
 	inputFilePath, hadTmpFile := a.inputFilesFIDL[path]
@@ -240,7 +240,7 @@
 			if !ok {
 				lib = &Library{
 					name:  libName,
-					deps:  make(map[fidlcommon.LibraryName]bool),
+					deps:  make(map[fidlgen.LibraryName]bool),
 					files: make(map[string]bool),
 					diags: make(map[state.FileID][]Diagnostic),
 				}
@@ -261,7 +261,7 @@
 		lib.files[inputFilePath] = true
 		imports := state.ParsePlatformImportsMatch(file)
 		for _, dep := range imports {
-			lib.deps[fidlcommon.LibraryName(dep.Lib)] = true
+			lib.deps[fidlgen.LibraryName(dep.Lib)] = true
 		}
 	}
 
@@ -325,7 +325,7 @@
 // IR for the library `lib`, or, if there is not a saved JSON file, generates
 // a path. It is used for fidlc invocations and for importing libraries' JSON
 // IR.
-func (a *Analyzer) pathToJSON(lib fidlcommon.LibraryName) string {
+func (a *Analyzer) pathToJSON(lib fidlgen.LibraryName) string {
 	if path, ok := a.inputFilesJSON[lib]; ok {
 		return path
 	}
diff --git a/fidl-lsp/analysis/compile.go b/fidl-lsp/analysis/compile.go
index bbc874c..65780a8 100644
--- a/fidl-lsp/analysis/compile.go
+++ b/fidl-lsp/analysis/compile.go
@@ -14,7 +14,7 @@
 	"strconv"
 	"strings"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -135,7 +135,7 @@
 		return err
 	}
 	// TODO: import more things? files + deps?
-	libName := fidlcommon.MustReadLibraryName(jsonIR.Name)
+	libName := fidlgen.MustReadLibraryName(jsonIR.Name)
 	lib, ok := a.getLibraryWithFile(libName, path)
 	if !ok {
 		lib = &Library{}
diff --git a/fidl-lsp/analysis/definition.go b/fidl-lsp/analysis/definition.go
index e9ccc30..c4dc49a 100644
--- a/fidl-lsp/analysis/definition.go
+++ b/fidl-lsp/analysis/definition.go
@@ -9,7 +9,7 @@
 	"io/ioutil"
 	"log"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -39,7 +39,7 @@
 func (a *Analyzer) DefinitionOfSymbol(fs *state.FileSystem, sym state.Symbol) ([]state.Location, error) {
 	// If `sym` is a library name, return locations pointing at all the files in
 	// the library (specifically, pointing at their `library` declarations).
-	libName, err := fidlcommon.ReadLibraryName(sym.Name)
+	libName, err := fidlgen.ReadLibraryName(sym.Name)
 	if err == nil {
 		// TODO: We could use getLibraryWithFile here, but it would be more
 		// complicated: if this library name is a declaration, we should pass it
diff --git a/fidl-lsp/analysis/definition_test.go b/fidl-lsp/analysis/definition_test.go
index 054cde0..7b69272 100644
--- a/fidl-lsp/analysis/definition_test.go
+++ b/fidl-lsp/analysis/definition_test.go
@@ -14,7 +14,7 @@
 
 var (
 	fuchsiaDir     = os.Getenv("FUCHSIA_DIR")
-	toolsPath      = fuchsiaDir + "/out/default.zircon/tools/"
+	toolsPath      = fuchsiaDir + "/out/default/host_x64/"
 	fidlcPath      = toolsPath + "fidlc"
 	fidlLintPath   = toolsPath + "fidl-lint"
 	fidlFormatPath = toolsPath + "fidl-format"
diff --git a/fidl-lsp/analysis/deps.go b/fidl-lsp/analysis/deps.go
index 24d6b00..b5165f5 100644
--- a/fidl-lsp/analysis/deps.go
+++ b/fidl-lsp/analysis/deps.go
@@ -10,7 +10,7 @@
 	"fmt"
 	"io/ioutil"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -46,13 +46,13 @@
 }
 
 // A libraryMap stores information derived about a group of libraries.
-type libraryMap map[fidlcommon.LibraryName]libraryInfo
+type libraryMap map[fidlgen.LibraryName]libraryInfo
 
 type libraryInfo struct {
 	// FIDL files that make up the library (relative to dir, or absolute).
 	files []string
 	// Direct dependencies (imported by "using" declarations in files).
-	deps []fidlcommon.LibraryName
+	deps []fidlgen.LibraryName
 }
 
 // empty returns true if i represents an empty library (has no files).
@@ -67,7 +67,7 @@
 
 	// Start with a stack containing the root library (if it's a platform source
 	// library, meaning we can expect to find it in the tree) and its imports.
-	var stack []fidlcommon.LibraryName
+	var stack []fidlgen.LibraryName
 	file, err := fs.File(path)
 	if err != nil {
 		return nil, fmt.Errorf("could not find file `%s`", path)
@@ -76,16 +76,16 @@
 	if !rootLibraryOk {
 		return nil, fmt.Errorf("no library found for file %s", file)
 	}
-	stack = append(stack, fidlcommon.LibraryName(rootLibraryMatch.Lib))
+	stack = append(stack, fidlgen.LibraryName(rootLibraryMatch.Lib))
 	rootImports := state.ParsePlatformImportsMatch(file)
 	for _, m := range rootImports {
-		stack = append(stack, fidlcommon.LibraryName(m.Lib))
+		stack = append(stack, fidlgen.LibraryName(m.Lib))
 	}
 
 	// Explore all dependencies via depth-first search.
 	for len(stack) != 0 {
 		// Pop a library and check if it needs processing.
-		var libName fidlcommon.LibraryName
+		var libName fidlgen.LibraryName
 		libName, stack = stack[len(stack)-1], stack[:len(stack)-1]
 		if _, ok := result[libName]; ok {
 			continue
@@ -158,9 +158,9 @@
 // directed graph in adjacency list form. In the resulting list, libraries only
 // depend on other libraries later in the list, not on earlier ones. Returns
 // an error if there is a cycle.
-func (m libraryMap) topologicalSort() ([]fidlcommon.LibraryName, error) {
-	var sorted []fidlcommon.LibraryName
-	incoming := map[fidlcommon.LibraryName]int{}
+func (m libraryMap) topologicalSort() ([]fidlgen.LibraryName, error) {
+	var sorted []fidlgen.LibraryName
+	incoming := map[fidlgen.LibraryName]int{}
 	for u := range m {
 		incoming[u] = 0
 	}
@@ -169,14 +169,14 @@
 			incoming[v]++
 		}
 	}
-	var src []fidlcommon.LibraryName
+	var src []fidlgen.LibraryName
 	for u, deg := range incoming {
 		if deg == 0 {
 			src = append(src, u)
 		}
 	}
 	for len(src) != 0 {
-		var u fidlcommon.LibraryName
+		var u fidlgen.LibraryName
 		u, src = src[len(src)-1], src[:len(src)-1]
 		sorted = append(sorted, u)
 		for _, v := range m[u].deps {
diff --git a/fidl-lsp/analysis/diagnostics.go b/fidl-lsp/analysis/diagnostics.go
index c8f7e4a..2c252b3 100644
--- a/fidl-lsp/analysis/diagnostics.go
+++ b/fidl-lsp/analysis/diagnostics.go
@@ -9,14 +9,14 @@
 	"fmt"
 	"os/exec"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
 
 // DiagnosticsOnLibrary retrieves the cached diagnostics for the library with
 // name `libName` including the file `path`.
-func (a *Analyzer) DiagnosticsOnLibrary(libName fidlcommon.LibraryName, path state.FileID) (map[state.FileID][]Diagnostic, error) {
+func (a *Analyzer) DiagnosticsOnLibrary(libName fidlgen.LibraryName, path state.FileID) (map[state.FileID][]Diagnostic, error) {
 	lib, ok := a.getLibraryWithFile(libName, path)
 	if !ok {
 		return nil, fmt.Errorf("could not find library `%s`", libName)
diff --git a/fidl-lsp/analysis/library.go b/fidl-lsp/analysis/library.go
index 1efa0f8..86b4661 100644
--- a/fidl-lsp/analysis/library.go
+++ b/fidl-lsp/analysis/library.go
@@ -4,13 +4,14 @@
 
 package analysis
 
-// Map from fully qualified name to type.kind, e.g.
-// "fuchsia.hardware.camera/Device": "interface"
-type decls map[string]string
+type externalDecl struct {
+	kind     string
+	resource *bool `json:"resource,omitempty"`
+}
 
 type dependency struct {
 	Name         string
-	Declarations decls
+	Declarations map[string]externalDecl
 }
 
 type location struct {
@@ -159,15 +160,15 @@
 type FidlLibrary struct {
 	Version        string
 	Name           string
-	Deps           []dependency    `json:"library_dependencies"`
-	BitsDecls      []bitsDecl      `json:"bits_declarations"`
-	ConstDecls     []constDecl     `json:"const_declarations"`
-	EnumDecls      []enumDecl      `json:"enum_declarations"`
-	ProtocolDecls  []protocolDecl  `json:"interface_declarations"`
-	ServiceDecls   []serviceDecl   `json:"service_declarations"`
-	StructDecls    []structDecl    `json:"struct_declarations"`
-	TableDecls     []tableDecl     `json:"table_declarations"`
-	UnionDecls     []unionDecl     `json:"union_declarations"`
-	TypeAliasDecls []typeAliasDecl `json:"type_alias_declarations"`
-	Decls          decls           `json:"declarations"`
+	Deps           []dependency      `json:"library_dependencies"`
+	BitsDecls      []bitsDecl        `json:"bits_declarations"`
+	ConstDecls     []constDecl       `json:"const_declarations"`
+	EnumDecls      []enumDecl        `json:"enum_declarations"`
+	ProtocolDecls  []protocolDecl    `json:"interface_declarations"`
+	ServiceDecls   []serviceDecl     `json:"service_declarations"`
+	StructDecls    []structDecl      `json:"struct_declarations"`
+	TableDecls     []tableDecl       `json:"table_declarations"`
+	UnionDecls     []unionDecl       `json:"union_declarations"`
+	TypeAliasDecls []typeAliasDecl   `json:"type_alias_declarations"`
+	Decls          map[string]string `json:"declarations"`
 }
diff --git a/fidl-lsp/analysis/references.go b/fidl-lsp/analysis/references.go
index 3e1b10e..2e773e8 100644
--- a/fidl-lsp/analysis/references.go
+++ b/fidl-lsp/analysis/references.go
@@ -9,7 +9,7 @@
 	"io/ioutil"
 	"log"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -25,7 +25,7 @@
 	// If `sym` is a library name, return locations pointing at all the files
 	// that import that library (specifically, pointing at their `using`
 	// declarations).
-	libName, err := fidlcommon.ReadLibraryName(sym.Name)
+	libName, err := fidlgen.ReadLibraryName(sym.Name)
 	if err == nil {
 		// TODO: We could use getLibraryWithFile here, but it would be more
 		// complicated: if this library name is a declaration, we should pass it
@@ -78,7 +78,7 @@
 	return refs, nil
 }
 
-func (a *Analyzer) importsOfLibrary(fs *state.FileSystem, importedLib fidlcommon.LibraryName) []state.Location {
+func (a *Analyzer) importsOfLibrary(fs *state.FileSystem, importedLib fidlgen.LibraryName) []state.Location {
 	libs := a.librariesThatImport(importedLib)
 	locs := []state.Location{}
 	for _, lib := range libs {
@@ -87,7 +87,7 @@
 	return locs
 }
 
-func (a *Analyzer) librariesThatImport(name fidlcommon.LibraryName) []*Library {
+func (a *Analyzer) librariesThatImport(name fidlgen.LibraryName) []*Library {
 	libs := []*Library{}
 	for _, lib := range a.libs {
 		for dep := range lib.deps {
@@ -100,7 +100,7 @@
 	return libs
 }
 
-func (a *Analyzer) importsOfLibraryInLibrary(fs *state.FileSystem, importedLib fidlcommon.LibraryName, library *Library) []state.Location {
+func (a *Analyzer) importsOfLibraryInLibrary(fs *state.FileSystem, importedLib fidlgen.LibraryName, library *Library) []state.Location {
 	files := []state.FileID{}
 	for file := range library.files {
 		// These files are all absolute paths, but some are to temporary input
@@ -140,7 +140,7 @@
 	return locs
 }
 
-func (a *Analyzer) typeReferencesName(t Type, name fidlcommon.Name) bool {
+func (a *Analyzer) typeReferencesName(t Type, name fidlgen.Name) bool {
 	if t.FromTypeAlias != nil {
 		if *t.FromTypeAlias == name.FullyQualifiedName() {
 			return true
diff --git a/fidl-lsp/analysis/symbol.go b/fidl-lsp/analysis/symbol.go
index a76e227..cd566aa 100644
--- a/fidl-lsp/analysis/symbol.go
+++ b/fidl-lsp/analysis/symbol.go
@@ -8,7 +8,7 @@
 	"fmt"
 	"strings"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -188,7 +188,7 @@
 
 type nameInLibrary struct {
 	lib  *Library // Left nil if uncertain
-	name fidlcommon.Name
+	name fidlgen.Name
 }
 
 func (a *Analyzer) symbolToFullyQualifiedName(fs *state.FileSystem, sym state.Symbol) (nameInLibrary, error) {
@@ -235,15 +235,15 @@
 		fqn = sym.Name[:i] + "/" + sym.Name[i+1:]
 	}
 
-	// Convert `fqn` to a fidlcommon.Name.
-	name, err := fidlcommon.ReadName(fqn)
+	// Convert `fqn` to a fidlgen.Name.
+	name, err := fidlgen.ReadName(fqn)
 	if err != nil {
 		return nameInLibrary{}, fmt.Errorf("could not read fully-qualified name `%s`: %s", fqn, err)
 	}
 	return nameInLibrary{lib: lib, name: name}, nil
 }
 
-func (a *Analyzer) lookupSymbolInfo(name fidlcommon.Name) (*symbolInfo, error) {
+func (a *Analyzer) lookupSymbolInfo(name fidlgen.Name) (*symbolInfo, error) {
 	// We don't call getLibraryWithFile here because we don't know for sure
 	// which library this symbol is part of. Unless the library is declared as a
 	// dependency of the library that includes this symbol, it couldn't be
@@ -256,7 +256,7 @@
 	return a.lookupSymbolInfoInLibrary(name, lib)
 }
 
-func (a *Analyzer) lookupSymbolInfoInLibrary(name fidlcommon.Name, lib *Library) (*symbolInfo, error) {
+func (a *Analyzer) lookupSymbolInfoInLibrary(name fidlgen.Name, lib *Library) (*symbolInfo, error) {
 	if lib.ir == nil {
 		if err := a.compileLibrary(lib); err != nil {
 			return nil, fmt.Errorf(
diff --git a/fidl-lsp/analysis/type.go b/fidl-lsp/analysis/type.go
index 041c4ec..0c7fcef 100644
--- a/fidl-lsp/analysis/type.go
+++ b/fidl-lsp/analysis/type.go
@@ -7,7 +7,7 @@
 import (
 	"fmt"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -18,7 +18,7 @@
 // description of the type.
 func (a *Analyzer) TypeOfSymbol(fs *state.FileSystem, sym state.Symbol) (Type, error) {
 	// If `sym` is a library name, return a `library`-kinded TypeInfo.
-	libName, err := fidlcommon.ReadLibraryName(sym.Name)
+	libName, err := fidlgen.ReadLibraryName(sym.Name)
 	if err == nil {
 		// TODO: We could use getLibraryWithFile here, but it would be more
 		// complicated: if this library name is a declaration, we should pass it
@@ -67,7 +67,7 @@
 		// This means that rather than being a declaration, symInfo is a value
 		// of an identifier type, so we lookup that type's info based on the
 		// type name.
-		typeName, err := fidlcommon.ReadName(symInfo.typeInfo.Identifier.Identifier)
+		typeName, err := fidlgen.ReadName(symInfo.typeInfo.Identifier.Identifier)
 		if err != nil {
 			return Type{}, fmt.Errorf(
 				"invalid identifier type `%s`: %s",
@@ -98,7 +98,7 @@
 		// This means that `sym` is a type alias to an identifier type, so we
 		// need to lookup that identifier type's info based on the type name.
 		aliasedType := symInfo.typeInfo.Identifier.TypeAlias.Type
-		typeName, err := fidlcommon.ReadName(aliasedType.Identifier.Identifier)
+		typeName, err := fidlgen.ReadName(aliasedType.Identifier.Identifier)
 		if err != nil {
 			return Type{}, fmt.Errorf(
 				"invalid identifier type `%s`: %s",
diff --git a/fidl-lsp/langserver/diagnostics.go b/fidl-lsp/langserver/diagnostics.go
index f8aef73..45ae043 100644
--- a/fidl-lsp/langserver/diagnostics.go
+++ b/fidl-lsp/langserver/diagnostics.go
@@ -9,7 +9,7 @@
 	"fmt"
 	"strings"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 	"github.com/sourcegraph/go-lsp"
 	"github.com/sourcegraph/jsonrpc2"
 
@@ -42,7 +42,7 @@
 		return nil, fmt.Errorf("could not find library name of file `%s`: %s", uri, err)
 	}
 
-	diags, err := h.analyzer.DiagnosticsOnLibrary(fidlcommon.LibraryName(libraryName), state.FileID(uri))
+	diags, err := h.analyzer.DiagnosticsOnLibrary(fidlgen.LibraryName(libraryName), state.FileID(uri))
 	if err != nil {
 		return nil, fmt.Errorf("error getting diagnostics: %s", err)
 	}
diff --git a/fidl-lsp/langserver/handler.go b/fidl-lsp/langserver/handler.go
index 7f4eec7..4d89a14 100644
--- a/fidl-lsp/langserver/handler.go
+++ b/fidl-lsp/langserver/handler.go
@@ -12,7 +12,7 @@
 	"os"
 	"strings"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 	"github.com/sourcegraph/go-lsp"
 	"github.com/sourcegraph/jsonrpc2"
 
@@ -64,7 +64,7 @@
 	fidlProjectPath string
 }
 
-func (c *Config) FormatRefURI(libraryName fidlcommon.LibraryName) string {
+func (c *Config) FormatRefURI(libraryName fidlgen.LibraryName) string {
 	return c.baseRefURI + libraryName.FullyQualifiedName()
 }
 
diff --git a/fidl-lsp/langserver/testutils.go b/fidl-lsp/langserver/testutils.go
index 527dcbb..23ffa06 100644
--- a/fidl-lsp/langserver/testutils.go
+++ b/fidl-lsp/langserver/testutils.go
@@ -14,7 +14,7 @@
 
 var (
 	fuchsiaDir     = os.Getenv("FUCHSIA_DIR")
-	toolsPath      = fuchsiaDir + "/out/default.zircon/tools/"
+	toolsPath      = fuchsiaDir + "/out/default/host_x64/"
 	fidlcPath      = toolsPath + "fidlc"
 	fidlLintPath   = toolsPath + "fidl-lint"
 	fidlFormatPath = toolsPath + "fidl-format"
diff --git a/fidl-lsp/scripts/copy_fidlgen_common.py b/fidl-lsp/scripts/copy_fidlgen_common.py
old mode 100644
new mode 100755
index b59abfa..a0ab1d2
--- a/fidl-lsp/scripts/copy_fidlgen_common.py
+++ b/fidl-lsp/scripts/copy_fidlgen_common.py
@@ -19,7 +19,7 @@
 from shutil import copyfile
 
 FUCHSIA_DIR = os.getenv('FUCHSIA_DIR')
-FIDLGEN_COMMON_PATH = 'garnet/go/src/fidl/compiler/backend/common/identifiers.go'
+FIDLGEN_COMMON_PATH = 'tools/fidl/lib/fidlgen/identifiers.go'
 
 
 def copy_fidlgen_common():
diff --git a/fidl-lsp/state/parse.go b/fidl-lsp/state/parse.go
index f91f9b3..4607641 100644
--- a/fidl-lsp/state/parse.go
+++ b/fidl-lsp/state/parse.go
@@ -9,7 +9,7 @@
 	"regexp"
 	"strings"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 )
 
 var (
@@ -47,7 +47,7 @@
 // and represents the location and value of a `library` or `using` declaration
 // in a FIDL file.
 type LibraryMatch struct {
-	Lib   fidlcommon.LibraryName
+	Lib   fidlgen.LibraryName
 	Range Range
 }
 
@@ -56,10 +56,10 @@
 
 // LibraryOfFile extracts the name of the FIDL library of the provided FIDL
 // file, by extracting its `library` declaration.
-func LibraryOfFile(file string) (fidlcommon.LibraryName, error) {
+func LibraryOfFile(file string) (fidlgen.LibraryName, error) {
 	fidlLib, ok := ParseLibraryMatch(file)
 	if !ok {
-		return fidlcommon.LibraryName{}, fmt.Errorf("Could not find library declaration in file")
+		return fidlgen.LibraryName{}, fmt.Errorf("Could not find library declaration in file")
 	}
 	return fidlLib.Lib, nil
 }
@@ -90,7 +90,7 @@
 
 func toLibraryMatch(fidl string, start, end int) LibraryMatch {
 	return LibraryMatch{
-		Lib: fidlcommon.MustReadLibraryName(fidl[start:end]),
+		Lib: fidlgen.MustReadLibraryName(fidl[start:end]),
 		Range: Range{
 			Start: Position{
 				Line:      strings.Count(fidl[:start], "\n"),
diff --git a/fidl-lsp/state/parse_test.go b/fidl-lsp/state/parse_test.go
index 6e32a0d..30e3dfc 100644
--- a/fidl-lsp/state/parse_test.go
+++ b/fidl-lsp/state/parse_test.go
@@ -7,7 +7,7 @@
 import (
 	"testing"
 
-	fidlcommon "fidl-lsp/third_party/common"
+	"fidl-lsp/third_party/fidlgen"
 
 	"fidl-lsp/state"
 )
@@ -55,7 +55,7 @@
 		t.Errorf("error getting library of file")
 	}
 	expLibrary := state.LibraryMatch{
-		Lib: fidlcommon.MustReadLibraryName("example"),
+		Lib: fidlgen.MustReadLibraryName("example"),
 		Range: state.Range{
 			Start: state.Position{Line: 1, Character: 8},
 			End:   state.Position{Line: 1, Character: 15},
@@ -75,7 +75,7 @@
 		t.Errorf("error getting library of file")
 	}
 	expLibrary = state.LibraryMatch{
-		Lib: fidlcommon.MustReadLibraryName("fuchsia.foo.bar"),
+		Lib: fidlgen.MustReadLibraryName("fuchsia.foo.bar"),
 		Range: state.Range{
 			Start: state.Position{Line: 2, Character: 8},
 			End:   state.Position{Line: 2, Character: 23},
@@ -107,14 +107,14 @@
 
 	expImports := []state.LibraryMatch{
 		{
-			Lib: fidlcommon.MustReadLibraryName("fuchsia.foo.bar"),
+			Lib: fidlgen.MustReadLibraryName("fuchsia.foo.bar"),
 			Range: state.Range{
 				Start: state.Position{Line: 2, Character: 6},
 				End:   state.Position{Line: 2, Character: 21},
 			},
 		},
 		{
-			Lib: fidlcommon.MustReadLibraryName("fuchsia.baz.qux"),
+			Lib: fidlgen.MustReadLibraryName("fuchsia.baz.qux"),
 			Range: state.Range{
 				Start: state.Position{Line: 3, Character: 6},
 				End:   state.Position{Line: 3, Character: 21},
diff --git a/fidl-lsp/third_party/common/copy_test.go b/fidl-lsp/third_party/fidlgen/copy_test.go
similarity index 83%
rename from fidl-lsp/third_party/common/copy_test.go
rename to fidl-lsp/third_party/fidlgen/copy_test.go
index 199e066..f46c69a 100644
--- a/fidl-lsp/third_party/common/copy_test.go
+++ b/fidl-lsp/third_party/fidlgen/copy_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-package common
+package fidlgen
 
 import (
 	"bytes"
@@ -21,8 +21,8 @@
 	if err != nil {
 		t.Fatalf("error reading identifiers.go in fidl-lsp: %s", err)
 	}
-	fidlgenCommonDir := fmt.Sprintf("%s/garnet/go/src/fidl/compiler/backend/common", os.Getenv("FUCHSIA_DIR"))
-	actualIdentifiersDotGo, err := ioutil.ReadFile(fmt.Sprintf("%s/identifiers.go", fidlgenCommonDir))
+	fidlgenDir := fmt.Sprintf("%s/tools/fidl/lib/fidlgen", os.Getenv("FUCHSIA_DIR"))
+	actualIdentifiersDotGo, err := ioutil.ReadFile(fmt.Sprintf("%s/identifiers.go", fidlgenDir))
 	if err != nil {
 		t.Fatalf("error reading identifiers.go in fuchsia.git: %s", err)
 	}
diff --git a/fidl-lsp/third_party/common/identifiers.go b/fidl-lsp/third_party/fidlgen/identifiers.go
similarity index 98%
rename from fidl-lsp/third_party/common/identifiers.go
rename to fidl-lsp/third_party/fidlgen/identifiers.go
index 85d3b9d..5247ec3 100644
--- a/fidl-lsp/third_party/common/identifiers.go
+++ b/fidl-lsp/third_party/fidlgen/identifiers.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-package common
+package fidlgen
 
 import (
 	"fmt"
@@ -73,7 +73,7 @@
 func MustReadLibraryName(fullyQualifiedName string) LibraryName {
 	name, err := ReadLibraryName(fullyQualifiedName)
 	if err != nil {
-		panic(err.Error())
+		panic(err)
 	}
 	return name
 }
@@ -103,7 +103,7 @@
 func MustReadName(fullyQualifiedName string) Name {
 	name, err := ReadName(fullyQualifiedName)
 	if err != nil {
-		panic(err.Error())
+		panic(err)
 	}
 	return name
 }