@@ -275,6 +275,8 @@ namespace ts {
275
275
export interface SolutionBuilder < T extends BuilderProgram > {
276
276
build ( project ?: string , cancellationToken ?: CancellationToken ) : ExitStatus ;
277
277
clean ( project ?: string ) : ExitStatus ;
278
+ buildReferences ( project : string , cancellationToken ?: CancellationToken ) : ExitStatus ;
279
+ cleanReferences ( project ?: string ) : ExitStatus ;
278
280
getNextInvalidatedProject ( cancellationToken ?: CancellationToken ) : InvalidatedProject < T > | undefined ;
279
281
280
282
// Currently used for testing but can be made public if needed:
@@ -565,7 +567,7 @@ namespace ts {
565
567
( state . buildOrder = createBuildOrder ( state , state . rootNames . map ( f => resolveProjectName ( state , f ) ) ) ) ;
566
568
}
567
569
568
- function getBuildOrderFor ( state : SolutionBuilderState , project : string | undefined ) {
570
+ function getBuildOrderFor ( state : SolutionBuilderState , project : string | undefined , onlyReferences : boolean | undefined ) {
569
571
const resolvedProject = project && resolveProjectName ( state , project ) ;
570
572
if ( resolvedProject ) {
571
573
const projectPath = toResolvedConfigFilePath ( state , resolvedProject ) ;
@@ -575,7 +577,10 @@ namespace ts {
575
577
) ;
576
578
if ( projectIndex === - 1 ) return undefined ;
577
579
}
578
- return resolvedProject ? createBuildOrder ( state , [ resolvedProject ] ) : getBuildOrder ( state ) ;
580
+ const buildOrder = resolvedProject ? createBuildOrder ( state , [ resolvedProject ] ) : getBuildOrder ( state ) ;
581
+ Debug . assert ( ! onlyReferences || resolvedProject !== undefined ) ;
582
+ Debug . assert ( ! onlyReferences || buildOrder [ buildOrder . length - 1 ] === resolvedProject ) ;
583
+ return onlyReferences ? buildOrder . slice ( 0 , buildOrder . length - 1 ) : buildOrder ;
579
584
}
580
585
581
586
function enableCache ( state : SolutionBuilderState ) {
@@ -653,7 +658,6 @@ namespace ts {
653
658
if ( state . options . watch ) { reportWatchStatus ( state , Diagnostics . Starting_compilation_in_watch_mode ) ; }
654
659
enableCache ( state ) ;
655
660
const buildOrder = getBuildOrder ( state ) ;
656
- reportBuildQueue ( state , buildOrder ) ;
657
661
buildOrder . forEach ( configFileName =>
658
662
state . projectPendingBuild . set (
659
663
toResolvedConfigFilePath ( state , configFileName ) ,
@@ -1186,7 +1190,11 @@ namespace ts {
1186
1190
! isIncrementalCompilation ( config . options ) ;
1187
1191
}
1188
1192
1189
- function getNextInvalidatedProject < T extends BuilderProgram > ( state : SolutionBuilderState < T > , buildOrder : readonly ResolvedConfigFileName [ ] ) : InvalidatedProject < T > | undefined {
1193
+ function getNextInvalidatedProject < T extends BuilderProgram > (
1194
+ state : SolutionBuilderState < T > ,
1195
+ buildOrder : readonly ResolvedConfigFileName [ ] ,
1196
+ reportQueue : boolean
1197
+ ) : InvalidatedProject < T > | undefined {
1190
1198
if ( ! state . projectPendingBuild . size ) return undefined ;
1191
1199
if ( state . currentInvalidatedProject ) {
1192
1200
// Only if same buildOrder the currentInvalidated project can be sent again
@@ -1202,6 +1210,11 @@ namespace ts {
1202
1210
const reloadLevel = state . projectPendingBuild . get ( projectPath ) ;
1203
1211
if ( reloadLevel === undefined ) continue ;
1204
1212
1213
+ if ( reportQueue ) {
1214
+ reportQueue = false ;
1215
+ reportBuildQueue ( state , buildOrder ) ;
1216
+ }
1217
+
1205
1218
const config = parseConfigFile ( state , project , projectPath ) ;
1206
1219
if ( ! config ) {
1207
1220
reportParseConfigFileDiagnostic ( state , projectPath ) ;
@@ -1678,17 +1691,19 @@ namespace ts {
1678
1691
}
1679
1692
}
1680
1693
1681
- function build ( state : SolutionBuilderState , project ?: string , cancellationToken ?: CancellationToken ) : ExitStatus {
1682
- const buildOrder = getBuildOrderFor ( state , project ) ;
1694
+ function build ( state : SolutionBuilderState , project ?: string , cancellationToken ?: CancellationToken , onlyReferences ?: boolean ) : ExitStatus {
1695
+ const buildOrder = getBuildOrderFor ( state , project , onlyReferences ) ;
1683
1696
if ( ! buildOrder ) return ExitStatus . InvalidProject_OutputsSkipped ;
1684
1697
1685
1698
setupInitialBuild ( state , cancellationToken ) ;
1686
1699
1700
+ let reportQueue = true ;
1687
1701
let successfulProjects = 0 ;
1688
1702
let errorProjects = 0 ;
1689
1703
while ( true ) {
1690
- const invalidatedProject = getNextInvalidatedProject ( state , buildOrder ) ;
1704
+ const invalidatedProject = getNextInvalidatedProject ( state , buildOrder , reportQueue ) ;
1691
1705
if ( ! invalidatedProject ) break ;
1706
+ reportQueue = false ;
1692
1707
invalidatedProject . done ( cancellationToken ) ;
1693
1708
if ( state . diagnostics . has ( invalidatedProject . projectPath ) ) {
1694
1709
errorProjects ++ ;
@@ -1709,8 +1724,8 @@ namespace ts {
1709
1724
ExitStatus . Success ;
1710
1725
}
1711
1726
1712
- function clean ( state : SolutionBuilderState , project ?: string ) {
1713
- const buildOrder = getBuildOrderFor ( state , project ) ;
1727
+ function clean ( state : SolutionBuilderState , project ?: string , onlyReferences ?: boolean ) {
1728
+ const buildOrder = getBuildOrderFor ( state , project , onlyReferences ) ;
1714
1729
if ( ! buildOrder ) return ExitStatus . InvalidProject_OutputsSkipped ;
1715
1730
1716
1731
const { options, host } = state ;
@@ -1783,7 +1798,7 @@ namespace ts {
1783
1798
state . projectErrorsReported . clear ( ) ;
1784
1799
reportWatchStatus ( state , Diagnostics . File_change_detected_Starting_incremental_compilation ) ;
1785
1800
}
1786
- const invalidatedProject = getNextInvalidatedProject ( state , getBuildOrder ( state ) ) ;
1801
+ const invalidatedProject = getNextInvalidatedProject ( state , getBuildOrder ( state ) , /*reportQueue*/ false ) ;
1787
1802
if ( invalidatedProject ) {
1788
1803
invalidatedProject . done ( ) ;
1789
1804
if ( state . projectPendingBuild . size ) {
@@ -1923,9 +1938,11 @@ namespace ts {
1923
1938
return {
1924
1939
build : ( project , cancellationToken ) => build ( state , project , cancellationToken ) ,
1925
1940
clean : project => clean ( state , project ) ,
1941
+ buildReferences : ( project , cancellationToken ) => build ( state , project , cancellationToken , /*onlyReferences*/ true ) ,
1942
+ cleanReferences : project => clean ( state , project , /*onlyReferences*/ true ) ,
1926
1943
getNextInvalidatedProject : cancellationToken => {
1927
1944
setupInitialBuild ( state , cancellationToken ) ;
1928
- return getNextInvalidatedProject ( state , getBuildOrder ( state ) ) ;
1945
+ return getNextInvalidatedProject ( state , getBuildOrder ( state ) , /*reportQueue*/ false ) ;
1929
1946
} ,
1930
1947
getBuildOrder : ( ) => getBuildOrder ( state ) ,
1931
1948
getUpToDateStatusOfProject : project => {
0 commit comments