internal/lsp: rename Files to CompiledGoFiles

As we improve support for cgo we'll need to reference GoFiles, not just
CompiledGoFiles. "Files" is right out.

I think I got everything that needs renaming but please let me know if
not.

Updates golang/go#35720.

Change-Id: I97a6ebf5b395535de0d5f4f8b3f84b46ca34643f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208101
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/cache/builtin.go b/internal/lsp/cache/builtin.go
index c634b60..597268c 100644
--- a/internal/lsp/cache/builtin.go
+++ b/internal/lsp/cache/builtin.go
@@ -21,7 +21,7 @@
 	return b.pkg.Scope.Lookup(name)
 }
 
-func (b *builtinPkg) Files() []source.ParseGoHandle {
+func (b *builtinPkg) CompiledGoFiles() []source.ParseGoHandle {
 	return b.files
 }
 
diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go
index 6158f8e..9472f9a 100644
--- a/internal/lsp/cache/check.go
+++ b/internal/lsp/cache/check.go
@@ -27,8 +27,8 @@
 type checkPackageHandle struct {
 	handle *memoize.Handle
 
-	// files are the ParseGoHandles that compose the package.
-	files []source.ParseGoHandle
+	// compiledGoFiles are the ParseGoHandles that compose the package.
+	compiledGoFiles []source.ParseGoHandle
 
 	// mode is the mode the the files were parsed in.
 	mode source.ParseMode
@@ -77,7 +77,7 @@
 	//
 
 	m := cph.m
-	files := cph.files
+	files := cph.compiledGoFiles
 	key := cph.key
 	fset := s.view.session.cache.fset
 
@@ -106,14 +106,14 @@
 	if m == nil {
 		return nil, nil, errors.Errorf("no metadata for %s", id)
 	}
-	phs, err := s.parseGoHandles(ctx, m, mode)
+	phs, err := s.compiledParseGoHandles(ctx, m, mode)
 	if err != nil {
 		return nil, nil, err
 	}
 	cph := &checkPackageHandle{
-		m:     m,
-		files: phs,
-		mode:  mode,
+		m:               m,
+		compiledGoFiles: phs,
+		mode:            mode,
 	}
 
 	// Make sure all of the depList are sorted.
@@ -139,7 +139,7 @@
 		deps[depHandle.m.pkgPath] = depHandle
 		depKeys = append(depKeys, depHandle.key)
 	}
-	cph.key = checkPackageKey(cph.m.id, cph.files, m.config, depKeys)
+	cph.key = checkPackageKey(cph.m.id, cph.compiledGoFiles, m.config, depKeys)
 	return cph, deps, nil
 }
 
@@ -177,8 +177,8 @@
 	return data.pkg, data.err
 }
 
-func (cph *checkPackageHandle) Files() []source.ParseGoHandle {
-	return cph.files
+func (cph *checkPackageHandle) CompiledGoFiles() []source.ParseGoHandle {
+	return cph.compiledGoFiles
 }
 
 func (cph *checkPackageHandle) ID() string {
@@ -206,9 +206,9 @@
 	return data.pkg, data.err
 }
 
-func (s *snapshot) parseGoHandles(ctx context.Context, m *metadata, mode source.ParseMode) ([]source.ParseGoHandle, error) {
-	phs := make([]source.ParseGoHandle, 0, len(m.files))
-	for _, uri := range m.files {
+func (s *snapshot) compiledParseGoHandles(ctx context.Context, m *metadata, mode source.ParseMode) ([]source.ParseGoHandle, error) {
+	phs := make([]source.ParseGoHandle, 0, len(m.compiledGoFiles))
+	for _, uri := range m.compiledGoFiles {
 		f, err := s.view.GetFile(ctx, uri)
 		if err != nil {
 			return nil, err
@@ -229,12 +229,12 @@
 	}
 
 	pkg := &pkg{
-		id:         m.id,
-		pkgPath:    m.pkgPath,
-		mode:       mode,
-		files:      phs,
-		imports:    make(map[packagePath]*pkg),
-		typesSizes: m.typesSizes,
+		id:              m.id,
+		pkgPath:         m.pkgPath,
+		mode:            mode,
+		compiledGoFiles: phs,
+		imports:         make(map[packagePath]*pkg),
+		typesSizes:      m.typesSizes,
 		typesInfo: &types.Info{
 			Types:      make(map[ast.Expr]types.TypeAndValue),
 			Defs:       make(map[*ast.Ident]types.Object),
@@ -245,11 +245,11 @@
 		},
 	}
 	var (
-		files       = make([]*ast.File, len(pkg.files))
-		parseErrors = make([]error, len(pkg.files))
+		files       = make([]*ast.File, len(pkg.compiledGoFiles))
+		parseErrors = make([]error, len(pkg.compiledGoFiles))
 		wg          sync.WaitGroup
 	)
-	for i, ph := range pkg.files {
+	for i, ph := range pkg.compiledGoFiles {
 		wg.Add(1)
 		go func(i int, ph source.ParseGoHandle) {
 			defer wg.Done()
diff --git a/internal/lsp/cache/gofile.go b/internal/lsp/cache/gofile.go
index 39c5a7c..497d1cb 100644
--- a/internal/lsp/cache/gofile.go
+++ b/internal/lsp/cache/gofile.go
@@ -117,7 +117,7 @@
 		if err != nil {
 			continue
 		}
-		for _, ph := range cph.Files() {
+		for _, ph := range cph.CompiledGoFiles() {
 			seen[ph.File().Identity().URI] = struct{}{}
 		}
 		results = append(results, cph)
@@ -135,7 +135,7 @@
 	metadata := s.getMetadataForURI(uri)
 
 	for _, m := range metadata {
-		for _, uri := range m.files {
+		for _, uri := range m.compiledGoFiles {
 			topLevelURIs[uri] = struct{}{}
 		}
 		s.reverseDependencies(m.id, uris, seen)
diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go
index 52b04da..f092fd7 100644
--- a/internal/lsp/cache/load.go
+++ b/internal/lsp/cache/load.go
@@ -20,14 +20,14 @@
 )
 
 type metadata struct {
-	id          packageID
-	pkgPath     packagePath
-	name        string
-	files       []span.URI
-	typesSizes  types.Sizes
-	errors      []packages.Error
-	deps        []packageID
-	missingDeps map[packagePath]struct{}
+	id              packageID
+	pkgPath         packagePath
+	name            string
+	compiledGoFiles []span.URI
+	typesSizes      types.Sizes
+	errors          []packages.Error
+	deps            []packageID
+	missingDeps     map[packagePath]struct{}
 
 	// config is the *packages.Config associated with the loaded package.
 	config *packages.Config
@@ -213,7 +213,7 @@
 	seen[id] = struct{}{}
 	for _, filename := range pkg.CompiledGoFiles {
 		uri := span.FileURI(filename)
-		m.files = append(m.files, uri)
+		m.compiledGoFiles = append(m.compiledGoFiles, uri)
 
 		s.addID(uri, m.id)
 	}
diff --git a/internal/lsp/cache/pkg.go b/internal/lsp/cache/pkg.go
index 316b98a..1716a4d 100644
--- a/internal/lsp/cache/pkg.go
+++ b/internal/lsp/cache/pkg.go
@@ -22,12 +22,12 @@
 	pkgPath packagePath
 	mode    source.ParseMode
 
-	files      []source.ParseGoHandle
-	errors     []*source.Error
-	imports    map[packagePath]*pkg
-	types      *types.Package
-	typesInfo  *types.Info
-	typesSizes types.Sizes
+	compiledGoFiles []source.ParseGoHandle
+	errors          []*source.Error
+	imports         map[packagePath]*pkg
+	types           *types.Package
+	typesInfo       *types.Info
+	typesSizes      types.Sizes
 }
 
 // Declare explicit types for package paths and IDs to ensure that we never use
@@ -44,12 +44,12 @@
 	return string(p.pkgPath)
 }
 
-func (p *pkg) Files() []source.ParseGoHandle {
-	return p.files
+func (p *pkg) CompiledGoFiles() []source.ParseGoHandle {
+	return p.compiledGoFiles
 }
 
 func (p *pkg) File(uri span.URI) (source.ParseGoHandle, error) {
-	for _, ph := range p.Files() {
+	for _, ph := range p.CompiledGoFiles() {
 		if ph.File().Identity().URI == uri {
 			return ph, nil
 		}
@@ -59,7 +59,7 @@
 
 func (p *pkg) GetSyntax() []*ast.File {
 	var syntax []*ast.File
-	for _, ph := range p.files {
+	for _, ph := range p.compiledGoFiles {
 		file, _, _, err := ph.Cached()
 		if err == nil {
 			syntax = append(syntax, file)
diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go
index 6b8da33..fddcf79 100644
--- a/internal/lsp/cache/snapshot.go
+++ b/internal/lsp/cache/snapshot.go
@@ -175,7 +175,7 @@
 		for importPath, newPkg := range cachedPkg.imports {
 			if oldPkg, ok := results[string(importPath)]; ok {
 				// Using the same trick as NarrowestPackageHandle, prefer non-variants.
-				if len(newPkg.files) < len(oldPkg.(*pkg).files) {
+				if len(newPkg.compiledGoFiles) < len(oldPkg.(*pkg).compiledGoFiles) {
 					results[string(importPath)] = newPkg
 				}
 			} else {
@@ -491,7 +491,7 @@
 	for _, parentID := range importedBy {
 		s.reverseDependencies(parentID, uris, seen)
 	}
-	for _, uri := range m.files {
+	for _, uri := range m.compiledGoFiles {
 		uris[uri] = struct{}{}
 	}
 }
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index 5ba18e2..1b35bbb 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -478,7 +478,7 @@
 
 func (v *view) findIgnoredFile(uri span.URI) (source.ParseGoHandle, source.Package, error) {
 	// Check the builtin package.
-	for _, h := range v.BuiltinPackage().Files() {
+	for _, h := range v.BuiltinPackage().CompiledGoFiles() {
 		if h.File().Identity().URI == uri {
 			return h, nil, nil
 		}
@@ -495,7 +495,7 @@
 		queue = queue[1:]
 		seen[pkg.ID()] = true
 
-		for _, ph := range pkg.Files() {
+		for _, ph := range pkg.CompiledGoFiles() {
 			if ph.File().Identity().URI == uri {
 				return ph, pkg, nil
 			}
diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go
index 206cc89..3519ad8 100644
--- a/internal/lsp/diagnostics.go
+++ b/internal/lsp/diagnostics.go
@@ -18,10 +18,10 @@
 
 func (s *Server) diagnoseView(view source.View, cphs []source.CheckPackageHandle) {
 	for _, cph := range cphs {
-		if len(cph.Files()) == 0 {
+		if len(cph.CompiledGoFiles()) == 0 {
 			continue
 		}
-		f := cph.Files()[0]
+		f := cph.CompiledGoFiles()[0]
 
 		// Run diagnostics on the workspace package.
 		go func(view source.View, uri span.URI) {
diff --git a/internal/lsp/source/completion_format.go b/internal/lsp/source/completion_format.go
index c39c342..190ef86 100644
--- a/internal/lsp/source/completion_format.go
+++ b/internal/lsp/source/completion_format.go
@@ -184,7 +184,7 @@
 
 	uri := span.FileURI(c.filename)
 	var ph ParseGoHandle
-	for _, h := range c.pkg.Files() {
+	for _, h := range c.pkg.CompiledGoFiles() {
 		if h.File().Identity().URI == uri {
 			ph = h
 		}
diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go
index e85c623..d90951d 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -69,7 +69,7 @@
 
 	// Prepare the reports we will send for the files in this package.
 	reports := make(map[span.URI][]Diagnostic)
-	for _, fh := range pkg.Files() {
+	for _, fh := range pkg.CompiledGoFiles() {
 		clearReports(view, reports, fh.File().Identity().URI)
 	}
 
@@ -95,7 +95,7 @@
 		if err != nil {
 			return nil, warningMsg, err
 		}
-		for _, fh := range pkg.Files() {
+		for _, fh := range pkg.CompiledGoFiles() {
 			clearReports(view, reports, fh.File().Identity().URI)
 		}
 		diagnostics(ctx, view, pkg, reports)
diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go
index 351b1a2..20ce807 100644
--- a/internal/lsp/source/format.go
+++ b/internal/lsp/source/format.go
@@ -117,7 +117,7 @@
 		return nil, nil, errors.Errorf("%s has list errors, not running goimports", f.URI())
 	}
 	var ph ParseGoHandle
-	for _, h := range pkg.Files() {
+	for _, h := range pkg.CompiledGoFiles() {
 		if h.File().Identity().URI == f.URI() {
 			ph = h
 		}
diff --git a/internal/lsp/source/highlight.go b/internal/lsp/source/highlight.go
index d4fdc82..f08258a 100644
--- a/internal/lsp/source/highlight.go
+++ b/internal/lsp/source/highlight.go
@@ -36,7 +36,7 @@
 		return nil, err
 	}
 	var ph ParseGoHandle
-	for _, file := range pkg.Files() {
+	for _, file := range pkg.CompiledGoFiles() {
 		if file.File().Identity().URI == f.URI() {
 			ph = file
 		}
diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go
index 257e309..48df4ba 100644
--- a/internal/lsp/source/identifier.go
+++ b/internal/lsp/source/identifier.go
@@ -110,7 +110,7 @@
 	view := snapshot.View()
 	uri := span.FileURI(view.Session().Cache().FileSet().Position(pos).Filename)
 	var ph ParseGoHandle
-	for _, h := range pkg.Files() {
+	for _, h := range pkg.CompiledGoFiles() {
 		if h.File().Identity().URI == uri {
 			ph = h
 		}
@@ -285,7 +285,7 @@
 	}
 	uri := span.FileURI(snapshot.View().Session().Cache().FileSet().Position(pos).Filename)
 	var ph ParseGoHandle
-	for _, h := range pkg.Files() {
+	for _, h := range pkg.CompiledGoFiles() {
 		if h.File().Identity().URI == uri {
 			ph = h
 		}
diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go
index 75208c8..4a4452f 100644
--- a/internal/lsp/source/implementation.go
+++ b/internal/lsp/source/implementation.go
@@ -62,7 +62,7 @@
 
 	for _, obj := range objs {
 		pkg := pkgs[obj]
-		if pkgs[obj] == nil || len(pkg.Files()) == 0 {
+		if pkgs[obj] == nil || len(pkg.CompiledGoFiles()) == 0 {
 			continue
 		}
 		file, _, _, err := i.Snapshot.View().FindPosInPackage(pkgs[obj], obj.Pos())
diff --git a/internal/lsp/source/util.go b/internal/lsp/source/util.go
index 443de11..57ad8d9 100644
--- a/internal/lsp/source/util.go
+++ b/internal/lsp/source/util.go
@@ -62,7 +62,7 @@
 	}
 	result := handles[0]
 	for _, handle := range handles[1:] {
-		if result == nil || len(handle.Files()) < len(result.Files()) {
+		if result == nil || len(handle.CompiledGoFiles()) < len(result.CompiledGoFiles()) {
 			result = handle
 		}
 	}
@@ -82,7 +82,7 @@
 	}
 	result := handles[0]
 	for _, handle := range handles[1:] {
-		if result == nil || len(handle.Files()) > len(result.Files()) {
+		if result == nil || len(handle.CompiledGoFiles()) > len(result.CompiledGoFiles()) {
 			result = handle
 		}
 	}
diff --git a/internal/lsp/source/view.go b/internal/lsp/source/view.go
index 1087514..0f64561 100644
--- a/internal/lsp/source/view.go
+++ b/internal/lsp/source/view.go
@@ -117,7 +117,7 @@
 	ID() string
 
 	// ParseGoHandle returns a ParseGoHandle for which to get the package.
-	Files() []ParseGoHandle
+	CompiledGoFiles() []ParseGoHandle
 
 	// Check returns the type-checked Package for the CheckPackageHandle.
 	Check(ctx context.Context) (Package, error)
@@ -333,7 +333,7 @@
 type Package interface {
 	ID() string
 	PkgPath() string
-	Files() []ParseGoHandle
+	CompiledGoFiles() []ParseGoHandle
 	File(uri span.URI) (ParseGoHandle, error)
 	GetSyntax() []*ast.File
 	GetErrors() []*Error
@@ -371,5 +371,5 @@
 
 type BuiltinPackage interface {
 	Lookup(name string) *ast.Object
-	Files() []ParseGoHandle
+	CompiledGoFiles() []ParseGoHandle
 }
diff --git a/internal/lsp/text_synchronization.go b/internal/lsp/text_synchronization.go
index 57e8b00..90c153b 100644
--- a/internal/lsp/text_synchronization.go
+++ b/internal/lsp/text_synchronization.go
@@ -175,7 +175,7 @@
 		return nil
 	}
 	for _, cph := range cphs {
-		for _, ph := range cph.Files() {
+		for _, ph := range cph.CompiledGoFiles() {
 			// If other files from this package are open, don't clear.
 			if s.session.IsOpen(ph.File().Identity().URI) {
 				clear = nil
diff --git a/internal/lsp/watched_files.go b/internal/lsp/watched_files.go
index 10e1a9a..de75c5f 100644
--- a/internal/lsp/watched_files.go
+++ b/internal/lsp/watched_files.go
@@ -55,7 +55,7 @@
 				// Find a different file in the same package we can use to trigger diagnostics.
 				// TODO(rstambler): Allow diagnostics to be called per-package to avoid this.
 				var otherFile source.File
-				for _, ph := range cph.Files() {
+				for _, ph := range cph.CompiledGoFiles() {
 					if ph.File().Identity().URI == f.URI() {
 						continue
 					}