diff --git a/pkg/checker/checker.go b/pkg/checker/checker.go index 97d7cfc06..5e5f08deb 100644 --- a/pkg/checker/checker.go +++ b/pkg/checker/checker.go @@ -2302,8 +2302,8 @@ func (c *Checker) checkSourceElementUnreachable(node *ast.Node) bool { sourceFile := ast.GetSourceFileOfNode(node) - start := node.Pos() - end := node.End() + startNode := node + endNode := node parent := node.Parent if parent.CanHaveStatements() { @@ -2333,14 +2333,14 @@ func (c *Checker) checkSourceElementUnreachable(node *ast.Node) bool { c.reportedUnreachableNodes.Add(nextNode) } - start = statements[first].Pos() - end = statements[last].End() + startNode = statements[first] + endNode = statements[last] } } - start = scanner.SkipTrivia(sourceFile.Text(), start) + start := scanner.GetTokenPosOfNode(startNode, sourceFile, false /*includeJSDoc*/) - diagnostic := ast.NewDiagnostic(sourceFile, core.NewTextRange(start, end), diagnostics.Unreachable_code_detected) + diagnostic := ast.NewDiagnostic(sourceFile, core.NewTextRange(start, endNode.End()), diagnostics.Unreachable_code_detected) c.addErrorOrSuggestion(c.compilerOptions.AllowUnreachableCode == core.TSFalse, diagnostic) return true diff --git a/pkg/pprof/pprof.go b/pkg/pprof/pprof.go index 554e7110f..2523c9488 100644 --- a/pkg/pprof/pprof.go +++ b/pkg/pprof/pprof.go @@ -6,8 +6,6 @@ import ( "os" "path/filepath" "runtime/pprof" - - "github.com/buke/typescript-go-internal/pkg/repo" ) type ProfileSession struct { @@ -63,12 +61,3 @@ func (p *ProfileSession) Stop() { fmt.Fprintf(p.logWriter, "CPU profile: %v\n", p.cpuFilePath) fmt.Fprintf(p.logWriter, "Memory profile: %v\n", p.memFilePath) } - -// ProfileInPprofDir is a convenience function that starts profiling in the 'pprof' directory under the repository root. -// The resulting files are logged to stderr. It returns a function that stops the profiling when called. -func ProfileInPprofDir() func() { - session := BeginProfiling(filepath.Join(repo.RootPath, "pprof"), os.Stderr) - return func() { - session.Stop() - } -}