7878import org .netbeans .spi .project .ActionProgress ;
7979import org .netbeans .spi .project .ActionProvider ;
8080import org .netbeans .api .project .ContainedProjectFilter ;
81+ import org .netbeans .spi .project .NestedClass ;
8182import org .netbeans .spi .project .ProjectConfiguration ;
8283import org .netbeans .spi .project .ProjectConfigurationProvider ;
8384import org .netbeans .spi .project .SingleMethod ;
@@ -126,14 +127,22 @@ protected void notifyFinished(DebugAdapterContext ctx, boolean success) {
126127 }
127128
128129 public final CompletableFuture <Void > nbLaunch (FileObject toRun , boolean preferProjActions , @ NullAllowed File nativeImageFile ,
129- @ NullAllowed String method , Map <String , Object > launchArguments , DebugAdapterContext context ,
130+ @ NullAllowed String method , @ NullAllowed String nestedClassName , Map <String , Object > launchArguments , DebugAdapterContext context ,
130131 boolean debug , boolean testRun , Consumer <NbProcessConsole .ConsoleMessage > consoleMessages ,
131132 boolean testInParallel ) {
132133 CompletableFuture <Void > launchFuture = new CompletableFuture <>();
133134 NbProcessConsole ioContext = new NbProcessConsole (consoleMessages );
135+ NestedClass nestedClass ;
136+ if (nestedClassName != null ) {
137+ nestedClass = new NestedClass (nestedClassName , toRun );
138+ } else {
139+ nestedClass = null ;
140+ }
134141 SingleMethod singleMethod ;
135142 if (method != null ) {
136- singleMethod = new SingleMethod (toRun , method );
143+ singleMethod = nestedClass != null ?
144+ new SingleMethod (toRun , method , nestedClass )
145+ : new SingleMethod (toRun , method );
137146 } else {
138147 singleMethod = null ;
139148 }
@@ -187,7 +196,7 @@ public void close() throws IOException {
187196 }
188197 }
189198 W writer = new W ();
190- CompletableFuture <Pair <ActionProvider , String >> commandFuture = findTargetWithPossibleRebuild (prj , preferProjActions , toRun , singleMethod , debug , testRun , ioContext , testInParallel , projectFilter );
199+ CompletableFuture <Pair <ActionProvider , String >> commandFuture = findTargetWithPossibleRebuild (prj , preferProjActions , toRun , singleMethod , nestedClass , debug , testRun , ioContext , testInParallel , projectFilter );
191200 commandFuture .thenAccept ((providerAndCommand ) -> {
192201 ExplicitProcessParameters params = createExplicitProcessParameters (launchArguments );
193202 OperationContext ctx = OperationContext .find (Lookup .getDefault ());
@@ -235,7 +244,7 @@ public void progressHandleCreated(ProgressOperationEvent e) {
235244 }
236245
237246 Lookup lookup = new ProxyLookup (
238- createTargetLookup (prj , singleMethod , toRun , projectFilter ),
247+ createTargetLookup (prj , singleMethod , nestedClass , toRun , projectFilter ),
239248 Lookups .fixed (runContext .toArray (new Object [runContext .size ()]))
240249 );
241250 // the execution Lookup is fully populated now. If the Project supports Configurations,
@@ -498,8 +507,8 @@ static List<String> argsToStringList(Object o) {
498507 }
499508 }
500509
501- private static CompletableFuture <Pair <ActionProvider , String >> findTargetWithPossibleRebuild (Project proj , boolean preferProjActions , FileObject toRun , SingleMethod singleMethod , boolean debug , boolean testRun , NbProcessConsole ioContext , boolean testInParallel , ContainedProjectFilter projectFilter ) throws IllegalArgumentException {
502- Pair <ActionProvider , String > providerAndCommand = findTarget (proj , preferProjActions , toRun , singleMethod , debug , testRun , testInParallel , projectFilter );
510+ private static CompletableFuture <Pair <ActionProvider , String >> findTargetWithPossibleRebuild (Project proj , boolean preferProjActions , FileObject toRun , SingleMethod singleMethod , NestedClass nestedClass , boolean debug , boolean testRun , NbProcessConsole ioContext , boolean testInParallel , ContainedProjectFilter projectFilter ) throws IllegalArgumentException {
511+ Pair <ActionProvider , String > providerAndCommand = findTarget (proj , preferProjActions , toRun , singleMethod , nestedClass , debug , testRun , testInParallel , projectFilter );
503512 if (providerAndCommand != null ) {
504513 return CompletableFuture .completedFuture (providerAndCommand );
505514 }
@@ -515,7 +524,7 @@ protected void started() {
515524 @ Override
516525 public void finished (boolean success ) {
517526 if (success ) {
518- Pair <ActionProvider , String > providerAndCommand = findTarget (proj , preferProjActions , toRun , singleMethod , debug , testRun , testInParallel , projectFilter );
527+ Pair <ActionProvider , String > providerAndCommand = findTarget (proj , preferProjActions , toRun , singleMethod , nestedClass , debug , testRun , testInParallel , projectFilter );
519528 if (providerAndCommand != null ) {
520529 afterBuild .complete (providerAndCommand );
521530 return ;
@@ -548,7 +557,7 @@ public void finished(boolean success) {
548557 return afterBuild ;
549558 }
550559
551- protected static @ CheckForNull Pair <ActionProvider , String > findTarget (Project prj , boolean preferProjActions , FileObject toRun , SingleMethod singleMethod , boolean debug , boolean testRun , boolean testInParallel , ContainedProjectFilter projectFilter ) {
560+ protected static @ CheckForNull Pair <ActionProvider , String > findTarget (Project prj , boolean preferProjActions , FileObject toRun , SingleMethod singleMethod , NestedClass nestedClass , boolean debug , boolean testRun , boolean testInParallel , ContainedProjectFilter projectFilter ) {
552561 ClassPath sourceCP = ClassPath .getClassPath (toRun , ClassPath .SOURCE );
553562 FileObject fileRoot = sourceCP != null ? sourceCP .findOwnerRoot (toRun ) : null ;
554563 boolean mainSource ;
@@ -560,7 +569,7 @@ public void finished(boolean success) {
560569 ActionProvider provider = null ;
561570 String command = null ;
562571 Collection <ActionProvider > actionProviders = findActionProviders (prj );
563- Lookup testLookup = createTargetLookup (preferProjActions ? prj : null , singleMethod , toRun , projectFilter );
572+ Lookup testLookup = createTargetLookup (preferProjActions ? prj : null , singleMethod , nestedClass , toRun , projectFilter );
564573 String [] actions ;
565574
566575 if (testInParallel ) {
@@ -577,7 +586,7 @@ public void finished(boolean success) {
577586 if (debug && !mainSource ) {
578587 // We are calling COMMAND_DEBUG_TEST_SINGLE instead of a missing COMMAND_DEBUG_TEST
579588 // This is why we need to add the file to the lookup
580- testLookup = createTargetLookup (null , singleMethod , toRun , projectFilter );
589+ testLookup = createTargetLookup (null , singleMethod , nestedClass , toRun , projectFilter );
581590 }
582591 } else {
583592 actions = debug ? mainSource ? new String [] {ActionProvider .COMMAND_DEBUG_SINGLE }
@@ -638,7 +647,7 @@ public void invokeAction(String command, Lookup context) throws IllegalArgumentE
638647 return Pair .of (provider , command );
639648 }
640649
641- static Lookup createTargetLookup (Project prj , SingleMethod singleMethod , FileObject toRun , ContainedProjectFilter projectFilter ) {
650+ static Lookup createTargetLookup (Project prj , SingleMethod singleMethod , NestedClass nestedClass , FileObject toRun , ContainedProjectFilter projectFilter ) {
642651 List <Lookup > arr = new ArrayList <>();
643652 if (prj != null ) {
644653 arr .add (Lookups .singleton (prj ));
@@ -647,6 +656,10 @@ static Lookup createTargetLookup(Project prj, SingleMethod singleMethod, FileObj
647656 Lookup methodLookup = Lookups .singleton (singleMethod );
648657 arr .add (methodLookup );
649658 }
659+ if (nestedClass != null ) {
660+ Lookup nestedClassLookup = Lookups .singleton (nestedClass );
661+ arr .add (nestedClassLookup );
662+ }
650663 if (projectFilter != null ) {
651664 Lookup projectLookup = Lookups .singleton (projectFilter );
652665 arr .add (projectLookup );
0 commit comments