1919package org .netbeans .modules .cpplite .project ;
2020
2121import java .io .File ;
22+ import java .util .ArrayList ;
2223import java .util .Collections ;
2324import java .util .List ;
2425import java .util .regex .Matcher ;
4950public class ActionProviderImpl implements ActionProvider {
5051 private static final String [] SUPPORTED_ACTIONS = {
5152 COMMAND_BUILD ,
53+ COMMAND_CLEAN ,
5254 COMMAND_REBUILD ,
5355 COMMAND_RUN ,
5456 COMMAND_DEBUG ,
@@ -59,8 +61,9 @@ public class ActionProviderImpl implements ActionProvider {
5961 public ActionProviderImpl (CPPLiteProject prj ) {
6062 this .prj = prj ;
6163 }
62-
64+
6365 @ Override
66+ @ SuppressWarnings ("ReturnOfCollectionOrArrayField" )
6467 public String [] getSupportedActions () {
6568 return SUPPORTED_ACTIONS ;
6669 }
@@ -84,7 +87,14 @@ public void invokeAction(String command, Lookup context) throws IllegalArgumentE
8487 List <List <String >> executablesFor = config .executablesFor (COMMAND_RUN );
8588 return Debugger .startInDebugger (executablesFor .get (0 ), FileUtil .toFile (prj .getProjectDirectory ()));
8689 }
87- List <List <String >> executablesFor = config .executablesFor (command );
90+ List <List <String >> executablesFor ;
91+ if (COMMAND_REBUILD .equals (command )) {
92+ executablesFor = new ArrayList <>();
93+ executablesFor .addAll (config .executablesFor (COMMAND_CLEAN ));
94+ executablesFor .addAll (config .executablesFor (COMMAND_BUILD ));
95+ } else {
96+ executablesFor = config .executablesFor (command );
97+ }
8898 String arg = executablesFor .stream ().map (c -> quote (c .stream ().map (p -> quote (p )).collect (Collectors .joining (" " )))).collect (Collectors .joining (" " ));
8999 return new ProcessBuilder ("java" , "-classpath" , module .getAbsolutePath (), Runner .class .getName (), arg ).directory (FileUtil .toFile (prj .getProjectDirectory ())).start ();
90100 }, executionDescriptor , ProjectUtils .getInformation (prj ).getDisplayName () + " - " + command ).run ();
@@ -97,11 +107,14 @@ private static String quote(String s) {
97107 @ Override
98108 public boolean isActionEnabled (String command , Lookup context ) throws IllegalArgumentException {
99109 if (COMMAND_DEBUG .equals (command )) {
100- command = COMMAND_RUN ;
110+ return isActionEnabled (COMMAND_RUN , context );
111+ } else if (COMMAND_REBUILD .equals (command )) {
112+ return isActionEnabled (COMMAND_CLEAN , context ) && isActionEnabled (COMMAND_BUILD , context );
113+ } else {
114+ return prj .getActiveBuildConfiguration ().executablesFor (command ) != null ;
101115 }
102- return prj .getActiveBuildConfiguration ().executablesFor (command ) != null ;
103116 }
104-
117+
105118 private static class ErrorLineConvertor implements LineConvertor {
106119
107120 @ Override
0 commit comments