Skip to content

Commit b4c4385

Browse files
committed
Rename compiler package to program
1 parent 4f6cc44 commit b4c4385

File tree

10 files changed

+34
-36
lines changed

10 files changed

+34
-36
lines changed

cmd/tsgo/main.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313

1414
"github.com/microsoft/typescript-go/internal/ast"
1515
"github.com/microsoft/typescript-go/internal/bundled"
16-
ts "github.com/microsoft/typescript-go/internal/compiler"
1716
"github.com/microsoft/typescript-go/internal/core"
1817
"github.com/microsoft/typescript-go/internal/diagnosticwriter"
18+
"github.com/microsoft/typescript-go/internal/program"
1919
"github.com/microsoft/typescript-go/internal/scanner"
2020
"github.com/microsoft/typescript-go/internal/tspath"
2121
"github.com/microsoft/typescript-go/internal/vfs"
@@ -86,7 +86,7 @@ func main() {
8686

8787
fs := bundled.WrapFS(vfs.FromOS())
8888
useCaseSensitiveFileNames := fs.UseCaseSensitiveFileNames()
89-
host := ts.NewCompilerHost(compilerOptions, currentDirectory, fs)
89+
host := program.NewCompilerHost(compilerOptions, currentDirectory, fs)
9090

9191
normalizedRootPath := tspath.ResolvePath(currentDirectory, rootPath)
9292
if !fs.DirectoryExists(normalizedRootPath) {
@@ -95,7 +95,7 @@ func main() {
9595
}
9696
compilerOptions.ConfigFilePath = normalizedRootPath // This matters for type reference directive resolution
9797

98-
programOptions := ts.ProgramOptions{
98+
programOptions := program.ProgramOptions{
9999
RootPath: normalizedRootPath,
100100
Options: compilerOptions,
101101
SingleThreaded: singleThreaded,
@@ -109,24 +109,24 @@ func main() {
109109
}
110110

111111
startTime := time.Now()
112-
program := ts.NewProgram(programOptions)
113-
diagnostics := program.GetSyntacticDiagnostics(nil)
112+
prog := program.NewProgram(programOptions)
113+
diagnostics := prog.GetSyntacticDiagnostics(nil)
114114
if len(diagnostics) == 0 {
115115
if parseAndBindOnly {
116-
diagnostics = program.GetBindDiagnostics(nil)
116+
diagnostics = prog.GetBindDiagnostics(nil)
117117
} else {
118118
if printTypes {
119-
program.PrintSourceFileWithTypes()
119+
prog.PrintSourceFileWithTypes()
120120
} else {
121-
diagnostics = program.GetSemanticDiagnostics(nil)
121+
diagnostics = prog.GetSemanticDiagnostics(nil)
122122
}
123123
}
124124
}
125125
compileTime := time.Since(startTime)
126126

127127
startTime = time.Now()
128128
if len(outDir) > 0 {
129-
result := program.Emit(&ts.EmitOptions{})
129+
result := prog.Emit(&program.EmitOptions{})
130130
diagnostics = append(diagnostics, result.Diagnostics...)
131131
}
132132
emitTime := time.Since(startTime)
@@ -157,13 +157,13 @@ func main() {
157157
}
158158

159159
if listFiles {
160-
for _, file := range program.SourceFiles() {
160+
for _, file := range prog.SourceFiles() {
161161
fmt.Println(file.FileName())
162162
}
163163
}
164164

165-
fmt.Printf("Files: %v\n", len(program.SourceFiles()))
166-
fmt.Printf("Types: %v\n", program.TypeCount())
165+
fmt.Printf("Files: %v\n", len(prog.SourceFiles()))
166+
fmt.Printf("Types: %v\n", prog.TypeCount())
167167
fmt.Printf("Compile time: %v\n", compileTime)
168168
fmt.Printf("Emit time: %v\n", emitTime)
169169
fmt.Printf("Memory used: %vK\n", memStats.Alloc/1024)

internal/checker/checker_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/microsoft/typescript-go/internal/ast"
88
"github.com/microsoft/typescript-go/internal/bundled"
9-
"github.com/microsoft/typescript-go/internal/compiler"
9+
"github.com/microsoft/typescript-go/internal/program"
1010
"github.com/microsoft/typescript-go/internal/vfs/vfstest"
1111
)
1212

@@ -26,13 +26,13 @@ foo.bar;`
2626
fs = bundled.WrapFS(fs)
2727

2828
cd := "/"
29-
host := compiler.NewCompilerHost(nil, "/", fs)
30-
opts := compiler.ProgramOptions{
29+
host := program.NewCompilerHost(nil, "/", fs)
30+
opts := program.ProgramOptions{
3131
Host: host,
3232
RootPath: cd,
3333
DefaultLibraryPath: bundled.LibPath(),
3434
}
35-
p := compiler.NewProgram(opts)
35+
p := program.NewProgram(opts)
3636
p.BindSourceFiles()
3737
c := p.GetTypeChecker()
3838
file := p.GetSourceFile("/foo.ts")

internal/compiler/pkg.go

Lines changed: 0 additions & 2 deletions
This file was deleted.

internal/compiler/emitHost.go renamed to internal/program/emitHost.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package program
22

33
import (
44
"github.com/microsoft/typescript-go/internal/ast"

internal/compiler/emitter.go renamed to internal/program/emitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package program
22

33
import (
44
"github.com/microsoft/typescript-go/internal/ast"

internal/compiler/host.go renamed to internal/program/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package program
22

33
import (
44
"github.com/microsoft/typescript-go/internal/core"

internal/compiler/program.go renamed to internal/program/program.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package program
22

33
import (
44
"cmp"

internal/compiler/program_test.go renamed to internal/program/program_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package program
22

33
import (
44
"strings"

internal/testutil/harnessutil/harnessutil.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212

1313
"github.com/microsoft/typescript-go/internal/ast"
1414
"github.com/microsoft/typescript-go/internal/bundled"
15-
"github.com/microsoft/typescript-go/internal/compiler"
1615
"github.com/microsoft/typescript-go/internal/core"
16+
"github.com/microsoft/typescript-go/internal/program"
1717
"github.com/microsoft/typescript-go/internal/repo"
1818
"github.com/microsoft/typescript-go/internal/tspath"
1919
"github.com/microsoft/typescript-go/internal/vfs"
@@ -28,7 +28,7 @@ type TestFile struct {
2828

2929
type CompileFilesResult struct {
3030
Diagnostics []*ast.Diagnostic
31-
Program *compiler.Program
31+
Program *program.Program
3232
// !!!
3333
}
3434

@@ -170,12 +170,12 @@ func setCompilerOptionsFromHarnessConfig(harnessConfig TestConfiguration, option
170170
}
171171
}
172172

173-
func createCompilerHost(fs vfs.FS, options *core.CompilerOptions, currentDirectory string) compiler.CompilerHost {
174-
return compiler.NewCompilerHost(options, currentDirectory, fs)
173+
func createCompilerHost(fs vfs.FS, options *core.CompilerOptions, currentDirectory string) program.CompilerHost {
174+
return program.NewCompilerHost(options, currentDirectory, fs)
175175
}
176176

177177
func compileFilesWithHost(
178-
host compiler.CompilerHost,
178+
host program.CompilerHost,
179179
rootFiles []string,
180180
options *core.CompilerOptions,
181181
typescriptVersion string,
@@ -211,7 +211,7 @@ func compileFilesWithHost(
211211
// pre-emit/post-emit error comparison requires declaration emit twice, which can be slow. If it's unlikely to flag any error consistency issues
212212
// and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too
213213
// skipErrorComparison := len(rootFiles) >= 100 || options.SkipLibCheck == core.TSTrue && options.Declaration == core.TSTrue
214-
// var preProgram *compiler.Program
214+
// var preProgram *program.Program
215215
// if !skipErrorComparison {
216216
// !!! Need actual program for this
217217
// preProgram = ts.createProgram({ rootNames: rootFiles || [], options: { ...compilerOptions, configFile: compilerOptions.configFile, traceResolution: false }, host, typeScriptVersion })
@@ -260,14 +260,14 @@ func compileFilesWithHost(
260260
}
261261

262262
// !!! Temporary while we don't have the real `createProgram`
263-
func createProgram(host compiler.CompilerHost, options *core.CompilerOptions) *compiler.Program {
264-
programOptions := compiler.ProgramOptions{
263+
func createProgram(host program.CompilerHost, options *core.CompilerOptions) *program.Program {
264+
programOptions := program.ProgramOptions{
265265
RootPath: "/", // Include all files while we don't have a way to specify root files
266266
Host: host,
267267
Options: options,
268268
DefaultLibraryPath: bundled.LibPath(),
269269
}
270-
program := compiler.NewProgram(programOptions)
270+
program := program.NewProgram(programOptions)
271271
return program
272272
}
273273

internal/testutil/tsbaseline/symbol_baseline.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/microsoft/typescript-go/internal/ast"
1212
"github.com/microsoft/typescript-go/internal/checker"
13-
"github.com/microsoft/typescript-go/internal/compiler"
13+
"github.com/microsoft/typescript-go/internal/program"
1414
"github.com/microsoft/typescript-go/internal/core"
1515
"github.com/microsoft/typescript-go/internal/scanner"
1616
"github.com/microsoft/typescript-go/internal/testutil/baseline"
@@ -28,7 +28,7 @@ func DoTypeAndSymbolBaseline(
2828
t *testing.T,
2929
baselinePath string,
3030
header string,
31-
program *compiler.Program,
31+
program *program.Program,
3232
allFiles []*harnessutil.TestFile,
3333
opts baseline.Options,
3434
skipTypeBaselines bool,
@@ -194,14 +194,14 @@ func iterateBaseline(allFiles []*harnessutil.TestFile, fullWalker *typeWriterWal
194194
}
195195

196196
type typeWriterWalker struct {
197-
program *compiler.Program
197+
program *program.Program
198198
checker *checker.Checker
199199
hadErrorBaseline bool
200200
currentSourceFile *ast.SourceFile
201201
declarationTextCache map[*ast.Node]string
202202
}
203203

204-
func newTypeWriterWalker(program *compiler.Program, hadErrorBaseline bool) *typeWriterWalker {
204+
func newTypeWriterWalker(program *program.Program, hadErrorBaseline bool) *typeWriterWalker {
205205
return &typeWriterWalker{
206206
checker: program.GetTypeChecker(),
207207
program: program,

0 commit comments

Comments
 (0)