Skip to content

Commit 5740abf

Browse files
made requested changes from prior ticket and did some cleanup
1 parent 2bb5c74 commit 5740abf

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

build/build.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
"github.com/fsnotify/fsnotify"
2828
"github.com/gopherjs/gopherjs/compiler"
2929
"github.com/gopherjs/gopherjs/compiler/astutil"
30-
"github.com/gopherjs/gopherjs/compiler/errorList"
3130
"github.com/gopherjs/gopherjs/compiler/jsFile"
3231
"github.com/gopherjs/gopherjs/compiler/sources"
32+
"github.com/gopherjs/gopherjs/internal/errorList"
3333
"github.com/gopherjs/gopherjs/internal/testmain"
3434
log "github.com/sirupsen/logrus"
3535

@@ -967,7 +967,7 @@ func (s *Session) loadTestPackage(pkg *PackageData) (*sources.Sources, error) {
967967
}
968968

969969
// Import dependencies for the testmain package.
970-
for _, importedPkgPath := range srcs.Imports() {
970+
for _, importedPkgPath := range srcs.UnresolvedImports() {
971971
_, _, err := s.loadImportPathWithSrcDir(importedPkgPath, pkg.Dir)
972972
if err != nil {
973973
return nil, err
@@ -1037,6 +1037,10 @@ var getExeModTime = func() func() time.Time {
10371037
}
10381038
}()
10391039

1040+
// loadPackages will recursively load and parse the given package and
1041+
// its dependencies. This will return the sources for the given package.
1042+
// The returned source and sources for the dependencies will be added
1043+
// to the session's sources map.
10401044
func (s *Session) loadPackages(pkg *PackageData) (*sources.Sources, error) {
10411045
if srcs, ok := s.sources[pkg.ImportPath]; ok {
10421046
return srcs, nil
@@ -1089,7 +1093,7 @@ func (s *Session) loadPackages(pkg *PackageData) (*sources.Sources, error) {
10891093

10901094
// Import dependencies from the augmented files,
10911095
// whilst skipping any that have been already imported.
1092-
for _, importedPkgPath := range srcs.Imports(pkg.Imports...) {
1096+
for _, importedPkgPath := range srcs.UnresolvedImports(pkg.Imports...) {
10931097
_, _, err := s.loadImportPathWithSrcDir(importedPkgPath, pkg.Dir)
10941098
if err != nil {
10951099
return nil, err

compiler/linkname.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"strings"
88

99
"github.com/gopherjs/gopherjs/compiler/astutil"
10-
"github.com/gopherjs/gopherjs/compiler/errorList"
1110
"github.com/gopherjs/gopherjs/compiler/internal/symbol"
11+
"github.com/gopherjs/gopherjs/internal/errorList"
1212
)
1313

1414
// GoLinkname describes a go:linkname compiler directive found in the source code.

compiler/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99

1010
"golang.org/x/tools/go/types/typeutil"
1111

12-
"github.com/gopherjs/gopherjs/compiler/errorList"
1312
"github.com/gopherjs/gopherjs/compiler/internal/analysis"
1413
"github.com/gopherjs/gopherjs/compiler/internal/dce"
1514
"github.com/gopherjs/gopherjs/compiler/internal/typeparams"
1615
"github.com/gopherjs/gopherjs/compiler/sources"
1716
"github.com/gopherjs/gopherjs/compiler/typesutil"
17+
"github.com/gopherjs/gopherjs/internal/errorList"
1818
"github.com/gopherjs/gopherjs/internal/experiments"
1919
)
2020

compiler/sources/errorCollectingImporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sources
33
import (
44
"go/types"
55

6-
"github.com/gopherjs/gopherjs/compiler/errorList"
6+
"github.com/gopherjs/gopherjs/internal/errorList"
77
)
88

99
// errorCollectingImporter implements go/types.Importer interface and

compiler/sources/sources.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"sort"
88
"strings"
99

10-
"github.com/gopherjs/gopherjs/compiler/errorList"
1110
"github.com/gopherjs/gopherjs/compiler/jsFile"
11+
"github.com/gopherjs/gopherjs/internal/errorList"
1212
"github.com/neelance/astrewrite"
1313
)
1414

@@ -114,12 +114,17 @@ func (s Sources) TypeCheck(importer types.Importer, sizes types.Sizes, tContext
114114
return typesInfo, typesPkg, nil
115115
}
116116

117-
// Imports calculates the import paths of the package's dependencies
117+
// UnresolvedImports calculates the import paths of the package's dependencies
118118
// based on all the imports in the augmented Go AST files.
119119
//
120-
// The given skip paths will not be returned in the results.
120+
// This is used to determine the unresolved imports that weren't in the
121+
// PackageData.Imports slice since they were added during augmentation or
122+
// during template generation.
123+
//
124+
// The given skip paths (typically those imports from PackageData.Imports)
125+
// will not be returned in the results.
121126
// This will not return any `*_test` packages in the results.
122-
func (s Sources) Imports(skip ...string) []string {
127+
func (s Sources) UnresolvedImports(skip ...string) []string {
123128
seen := make(map[string]struct{})
124129
for _, sk := range skip {
125130
seen[sk] = struct{}{}
File renamed without changes.

tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
gbuild "github.com/gopherjs/gopherjs/build"
2727
"github.com/gopherjs/gopherjs/build/cache"
2828
"github.com/gopherjs/gopherjs/compiler"
29-
"github.com/gopherjs/gopherjs/compiler/errorList"
29+
"github.com/gopherjs/gopherjs/internal/errorList"
3030
"github.com/gopherjs/gopherjs/internal/sysutil"
3131
"github.com/neelance/sourcemap"
3232
log "github.com/sirupsen/logrus"

0 commit comments

Comments
 (0)