11package org .codechecker .eclipse .plugin .config ;
22
3+ import java .nio .file .Path ;
34import java .nio .file .Paths ;
4- import java .util .ArrayList ;
55import java .util .HashMap ;
6- import java .util .List ;
76import java .util .Map ;
87
98import org .codechecker .eclipse .plugin .Logger ;
1716import org .codechecker .eclipse .plugin .config .Config .ConfigTypes ;
1817import org .codechecker .eclipse .plugin .config .global .CcGlobalConfiguration ;
1918import org .codechecker .eclipse .plugin .config .project .CodeCheckerProject ;
20- import org .codechecker .eclipse .plugin .itemselector .CheckerView ;
2119import org .codechecker .eclipse .plugin .runtime .ShellExecutorHelperFactory ;
22- import org .codechecker .eclipse .plugin .utils .CheckerItem ;
23- import org .codechecker .eclipse .plugin .utils .CheckerItem .LAST_ACTION ;
2420import org .eclipse .core .resources .IProject ;
2521import org .eclipse .core .runtime .IStatus ;
26- import org .eclipse .jface .action .Action ;
2722import org .eclipse .jface .dialogs .IMessageProvider ;
2823import org .eclipse .jface .layout .GridDataFactory ;
2924import org .eclipse .jface .layout .GridLayoutFactory ;
4035import org .eclipse .swt .widgets .FileDialog ;
4136import org .eclipse .swt .widgets .Group ;
4237import org .eclipse .swt .widgets .Label ;
43- import org .eclipse .swt .widgets .Shell ;
4438import org .eclipse .swt .widgets .Text ;
4539import org .eclipse .ui .IWorkbench ;
46- import org .eclipse .ui .PlatformUI ;
4740import org .eclipse .ui .forms .widgets .ColumnLayout ;
4841import org .eclipse .ui .forms .widgets .ExpandableComposite ;
4942import org .eclipse .ui .forms .widgets .FormToolkit ;
@@ -60,14 +53,14 @@ public class CommonGui {
6053
6154 private static final String VALID_PACKAGE = "CodeChecker being used: " ;
6255 private static final String BROSWE = "Browse" ;
63- private static final String CHECKER_ENABLED = " -e " ;
64- private static final String CHECKER_DISABLED = " -d " ;
65- private static final String CHECKER_SEPARATOR = " " ;
6656
6757 private static final int TEXTWIDTH = 200 ;
6858 private static final int FORM_COLUMNS = 3 ;
6959 private static final int FORM_ONE_ROW = 1 ;
7060
61+ private static final int AN_CMD_DISP_HGT = 300 ;
62+ private static final int TRI_LINE_TEXT_HGT = 52 ;
63+
7164 private boolean globalGui ;// whether this class is for global or project
7265 // specific preferences
7366 private boolean useGlobalSettings ;// if this is project specific page,
@@ -94,6 +87,9 @@ public class CommonGui {
9487 private Button globalcc ;
9588 private Button projectcc ;
9689
90+ private Text analysisOptions ;
91+ private Text analysisCmdDisplay ;
92+
9793 /**
9894 * Constructor to be used, when only global preferences are to be set.
9995 */
@@ -181,32 +177,36 @@ public Control createContents(final Composite parent) {
181177 cLoggers = addTextField (toolkit , comp , "Compiler commands to log" , "gcc:g++:clang:clang++" );
182178 toolkit .createLabel (comp , "" );
183179
184- final Button checkers = toolkit .createButton (comp , "Toggle enabled checkers" , SWT .PUSH );
185- checkers .addSelectionListener (new SelectionAdapter () {
186-
187- public void widgetSelected (SelectionEvent e ) {
188- Action action = new Action () {
189- @ Override
190- public void run () {
191- Shell activeShell = PlatformUI .getWorkbench ().getActiveWorkbenchWindow ().getShell ();
192- //Map<ConfigTypes, String> config = getConfigFromFields();
193- try {
194- ArrayList <CheckerItem > checkersList = getCheckerList ();
195- CheckerView dialog = new CheckerView (activeShell , checkersList );
196-
197- int result = dialog .open ();
198- if (result == 0 ) {
199- checkerListArg = checkerListToCheckerListArg (dialog .getCheckersList ());
200- }
201- } catch (IllegalArgumentException e ) {
202- Logger .log (IStatus .INFO , "Codechecker environment is invalid" + e );
203- }
204- }
205- };
206- action .run ();
180+ toolkit .createLabel (comp , "Extra analysis options" );
181+ analysisOptions = toolkit .createText (comp , "" , SWT .WRAP | SWT .BORDER | SWT .V_SCROLL );
182+ GridDataFactory .fillDefaults ().grab (false , true ).hint (TEXTWIDTH , TRI_LINE_TEXT_HGT ).applyTo (analysisOptions );
183+ analysisOptions .addModifyListener (new ModifyListener () {
184+
185+ @ Override
186+ public void modifyText (ModifyEvent e ) {
187+ config .get ().put (ConfigTypes .ANAL_OPTIONS , analysisOptions .getText ());
188+ Path originalLogFile = null ;
189+ if (!globalGui ) {
190+ originalLogFile = cCProject .getLogFileLocation ();
191+ }
192+ if (codeChecker != null )
193+ analysisCmdDisplay .setText (codeChecker .getAnalyzeString (config , originalLogFile ));
194+ checkerConfigSection .layout ();
195+ checkerConfigSection .getParent ().layout ();
196+ comp .layout (true );
197+ comp .getParent ().layout (true );
207198 }
208199 });
209- checkers .setData ("org.eclipse.swtbot.widget.checkersKey" , "checkesButton" );
200+ analysisOptions .getVerticalBar ().setEnabled (true );
201+
202+ toolkit .createLabel (comp , "" );
203+ toolkit .createLabel (comp , "Final analysis command" );
204+ analysisCmdDisplay = toolkit .createText (comp , "" , SWT .MULTI | SWT .WRAP | SWT .V_SCROLL );
205+ GridDataFactory .fillDefaults ().grab (false , true ).hint (TEXTWIDTH , AN_CMD_DISP_HGT ).applyTo (analysisCmdDisplay );
206+ analysisCmdDisplay .setEditable (false );
207+ analysisCmdDisplay .getVerticalBar ().setEnabled (true );
208+ toolkit .createLabel (comp , "" );
209+
210210 if (!globalGui ) {
211211 recursiveSetEnabled (form .getBody (), !useGlobalSettings );
212212 final Composite client3 = toolkit .createComposite (globalConfigSection );
@@ -382,61 +382,6 @@ public void recursiveSetEnabled(Control control, Boolean b) {
382382 }
383383 }
384384
385- /**
386- * Returns The all checkers from CodeChecker.
387- * @return A list of all available checkers.
388- */
389- private ArrayList <CheckerItem > getCheckerList () {
390- // ArrayList<CheckerItem> defaultCheckersList = new ArrayList<>();
391- ArrayList <CheckerItem > checkersList = new ArrayList <>(); //
392- // new Checkers List
393- String s = codeChecker .getCheckers ();
394- String [] newCheckersSplit = s .split ("\n " );
395- // old Checkers Command
396- //String[] checkersCommand = checkerListArg.split(CHECKER_SEPARATOR);
397- //List<String> oldCheckersCommand = Arrays.asList(checkersCommand);
398- for (String it : newCheckersSplit ) {
399- // String checkerName = it.split(" ")[2];
400- String checkerName = it ;
401- CheckerItem check = new CheckerItem (checkerName );
402- boolean defaultEnabled = false ;
403-
404- if (it .split (CHECKER_SEPARATOR )[1 ].equals ("+" ))
405- defaultEnabled = true ;
406- if (defaultEnabled ) {
407- if (checkerListArg .contains (CHECKER_DISABLED + checkerName )) {
408- check .setLastAction (LAST_ACTION .DESELECTION );
409- } else {
410- check .setLastAction (LAST_ACTION .SELECTION );
411- }
412- } else {
413- if (checkerListArg .contains (CHECKER_ENABLED + checkerName )) {
414- check .setLastAction (LAST_ACTION .SELECTION );
415- } else {
416- check .setLastAction (LAST_ACTION .DESELECTION );
417- }
418- }
419- checkersList .add (check );
420- }
421- return checkersList ;
422- }
423-
424- /**
425- * Returns Stringified checkerlist configuration.
426- * @param chl The internal list of checkers.
427- * @return The string list of checkers prefixed with state.
428- */
429- protected String checkerListToCheckerListArg (List <CheckerItem > chl ) {
430- StringBuilder checkerListArg = new StringBuilder ();
431- for (int i = 0 ; i < chl .size (); ++i ) {
432- if (chl .get (i ).getLastAction () == LAST_ACTION .SELECTION )
433- checkerListArg .append (CHECKER_ENABLED + chl .get (i ).getText () + CHECKER_SEPARATOR );
434- else
435- checkerListArg .append (CHECKER_DISABLED + chl .get (i ).getText () + CHECKER_SEPARATOR );
436- }
437- return checkerListArg .toString ();
438- }
439-
440385 /**
441386 * Loads config from {@link CcConfiguration}.
442387 * @param resetToDefault If set, the default config is used.
@@ -469,9 +414,9 @@ public void setFields() {
469414 break ;
470415 }
471416 codeCheckerDirectoryField .setText (config .get (ConfigTypes .CHECKER_PATH ));
472- checkerListArg = config .get (ConfigTypes .CHECKER_LIST );
473417 cLoggers .setText (config .get (ConfigTypes .COMPILERS ));
474418 numThreads .setText (config .get (ConfigTypes .ANAL_THREADS ));
419+ analysisOptions .setText (config .get (ConfigTypes .ANAL_OPTIONS ));
475420 }
476421
477422 /**
@@ -481,7 +426,6 @@ public void setFields() {
481426 public Map <ConfigTypes , String > getConfigFromFields () {
482427 Map <ConfigTypes , String > conf = new HashMap <>();
483428 conf .put (ConfigTypes .CHECKER_PATH , codeCheckerDirectoryField .getText ());
484- conf .put (ConfigTypes .CHECKER_LIST , checkerListArg );
485429 conf .put (ConfigTypes .ANAL_THREADS , numThreads .getText ());
486430 conf .put (ConfigTypes .COMPILERS , cLoggers .getText ());
487431 return conf ;
@@ -493,7 +437,7 @@ public Map<ConfigTypes, String> getConfigFromFields() {
493437 public void saveConfig () {
494438 Map <ConfigTypes , String > conf = new HashMap <ConfigTypes , String >();
495439 conf .put (ConfigTypes .CHECKER_PATH , codeCheckerDirectoryField .getText ());
496- conf .put (ConfigTypes .CHECKER_LIST , checkerListArg );
440+ conf .put (ConfigTypes .ANAL_OPTIONS , analysisOptions . getText () );
497441 conf .put (ConfigTypes .ANAL_THREADS , numThreads .getText ());
498442 conf .put (ConfigTypes .COMPILERS , cLoggers .getText ());
499443 conf .put (ConfigTypes .RES_METHOD , currentResMethod .toString ());
0 commit comments