@@ -130,15 +130,8 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
130
130
SloeberProject sloeberProject = new SloeberProject (project );
131
131
CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
132
132
ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (project , true );
133
- if (upgradeArduinoProject (sloeberProject , prjCDesc )) {
134
- try {
135
- cCorePlugin .setProjectDescription (project , prjCDesc );
136
- } catch (CoreException e ) {
137
- e .printStackTrace ();
138
- }
139
- }
133
+ upgradeArduinoProject (sloeberProject , prjCDesc );
140
134
if (!sloeberProject .readConfigFromFiles ()) {
141
- String RELEASE = "Release" ;
142
135
sloeberProject .setBoardDescription (RELEASE , new BoardDescription (), false );
143
136
sloeberProject .setCompileDescription (RELEASE , new CompileDescription ());
144
137
sloeberProject .setOtherDescription (RELEASE , new OtherDescription ());
@@ -182,7 +175,6 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
182
175
183
176
ManagedBuildManager .setDefaultConfiguration (project , defaultConfig );
184
177
185
- prjCDesc = cCorePlugin .getProjectDescription (project );
186
178
ICConfigurationDescription activeConfig = prjCDesc .getActiveConfiguration ();
187
179
188
180
for (String curConfigName : sloeberProject .myBoardDescriptions .keySet ()) {
@@ -361,7 +353,7 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
361
353
/**
362
354
* This method asks for a Sloeber project in an old form and creates a sloeber
363
355
* project in a new for
364
- * currently only 1 conversion is implemented
356
+ * currently only the conversion storage in CDT to .sProject is implemented
365
357
*
366
358
* returns true if the projectdescription needs to be saved
367
359
*/
@@ -475,11 +467,33 @@ public synchronized boolean configure(ICProjectDescription prjCDesc, boolean prj
475
467
476
468
setAllEnvironmentVars ();
477
469
470
+ List <String > newConfigs = newConfigsNeededInCDT (prjCDesc );
478
471
if (prjDescWritable ) {
479
- List <String > newConfigs = newConfigNeededInCDT (prjCDesc );
480
472
if (newConfigs .size () > 0 ) {
481
473
saveProjDesc = saveProjDesc || createNeededCDTConfigs (newConfigs , prjCDesc );
482
474
}
475
+ } else {
476
+ saveProjDesc = saveProjDesc || (newConfigs .size () > 0 );
477
+ if (saveProjDesc ) {
478
+ final IWorkspace workspace = ResourcesPlugin .getWorkspace ();
479
+ try {
480
+ workspace .run (new ICoreRunnable () {
481
+
482
+ @ Override
483
+ public void run (IProgressMonitor monitor ) throws CoreException {
484
+ CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
485
+ ICProjectDescription prjCDescSave = cCorePlugin .getProjectDescription (myProject , true );
486
+ if (configure (prjCDescSave , true )) {
487
+ cCorePlugin .setProjectDescription (myProject , prjCDescSave , false , null );
488
+ }
489
+
490
+ }
491
+ }, null , IWorkspace .AVOID_UPDATE , null );
492
+ } catch (Exception e ) {
493
+ Common .log (new Status (IStatus .INFO , io .sloeber .core .Activator .getId (),
494
+ "Failed to do posponed confdesc saving for project " + myProject .getName (), e )); //$NON-NLS-1$
495
+ }
496
+ }
483
497
}
484
498
485
499
myIsInMemory = true ;
@@ -610,7 +624,7 @@ private boolean readConfigFromCDT(ICProjectDescription prjCDesc) {
610
624
* @param prjCDesc
611
625
* @return a list of sloeber known configurationNames unknown to CDT
612
626
*/
613
- private List <String > newConfigNeededInCDT (ICProjectDescription prjCDesc ) {
627
+ private List <String > newConfigsNeededInCDT (ICProjectDescription prjCDesc ) {
614
628
List <String > ret = new LinkedList <>();
615
629
for (String curConfName : myBoardDescriptions .keySet ()) {
616
630
ICConfigurationDescription curConfDesc = prjCDesc .getConfigurationByName (curConfName );
@@ -628,7 +642,7 @@ private List<String> newConfigNeededInCDT(ICProjectDescription prjCDesc) {
628
642
* @param configs
629
643
* @param prjCDesc
630
644
* @return true if at least one config was created (basically only false if
631
- * configs is empty)
645
+ * configs is empty oe error conditions )
632
646
*/
633
647
private static boolean createNeededCDTConfigs (List <String > configs , ICProjectDescription prjCDesc ) {
634
648
boolean ret = false ;
@@ -639,6 +653,7 @@ private static boolean createNeededCDTConfigs(List<String> configs, ICProjectDes
639
653
ret = true ;
640
654
} catch (Exception e ) {
641
655
// ignore as we will try again later
656
+ e .printStackTrace ();
642
657
}
643
658
}
644
659
return ret ;
@@ -823,8 +838,11 @@ public static SloeberProject getSloeberProject(IProject project) {
823
838
try {
824
839
sessionProperty = project .getSessionProperty (sloeberQualifiedName );
825
840
if (null != sessionProperty ) {
826
- SloeberProject ret = (SloeberProject ) sessionProperty ;
827
- return ret ;
841
+ SloeberProject sloeberProject = (SloeberProject ) sessionProperty ;
842
+ if (sloeberProject .isInMemory ()) {
843
+ IndexerController .index (project );
844
+ }
845
+ return sloeberProject ;
828
846
}
829
847
} catch (CoreException e ) {
830
848
e .printStackTrace ();
@@ -939,14 +957,14 @@ private static String getOtherPrefix(String confDescName) {
939
957
* Get the file that Sloeber maintains and that is meant to be stored in version control
940
958
*/
941
959
private IFile getConfigVersionFile () {
942
- return myProject . getFile ( SLOEBER_CFG );
960
+ return Sketch . getConfigVersionFile ( myProject );
943
961
}
944
962
945
963
/*
946
964
* Get the sloeber configuration file
947
965
*/
948
966
private IFile getConfigLocalFile () {
949
- return myProject . getFile ( ".sproject" ); //$NON-NLS-1$
967
+ return Sketch . getConfigLocalFile ( myProject );
950
968
}
951
969
952
970
public void configChangeAboutToApply (ICProjectDescription newProjDesc , ICProjectDescription oldProjDesc ) {
@@ -1037,20 +1055,23 @@ public void configChangeAboutToApply(ICProjectDescription newProjDesc, ICProject
1037
1055
*
1038
1056
*/
1039
1057
public void sloeberCfgChanged () {
1040
- CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
1041
- ICProjectDescription projDesc = cCorePlugin .getProjectDescription (myProject , true );
1042
- ICConfigurationDescription activeConfig = projDesc .getActiveConfiguration ();
1058
+ // CCorePlugin cCorePlugin = CCorePlugin.getDefault();
1059
+ // ICProjectDescription projDesc = cCorePlugin.getProjectDescription(myProject, true);
1060
+ /// ICConfigurationDescription activeConfig = projDesc.getActiveConfiguration();
1043
1061
myIsInMemory = false ;
1044
- boolean projDescNeedsSaving = configure (projDesc , true );
1045
- Helpers .deleteBuildFolder (myProject , activeConfig .getName ());
1046
- projDescNeedsSaving = projDescNeedsSaving || setActiveConfig (activeConfig );
1047
- if (projDescNeedsSaving ) {
1048
- try {
1049
- cCorePlugin .setProjectDescription (myProject , projDesc );
1050
- } catch (CoreException e ) {
1051
- e .printStackTrace ();
1052
- }
1053
- }
1062
+ configure ();
1063
+ //all configs may have changed so only deleting the active config does not make sense
1064
+ //Helpers.deleteBuildFolder(myProject, activeConfig.getName());
1065
+
1066
+ //This code is only triggered when sloeber.cfg changed so no need to set the active config
1067
+ //projDescNeedsSaving = projDescNeedsSaving || setActiveConfig(activeConfig);
1068
+ // if (projDescNeedsSaving) {
1069
+ // try {
1070
+ // cCorePlugin.setProjectDescription(myProject, projDesc);
1071
+ // } catch (CoreException e) {
1072
+ // e.printStackTrace();
1073
+ // }
1074
+ // }
1054
1075
1055
1076
}
1056
1077
@@ -1116,7 +1137,7 @@ private IStatus BuildTarget(String targetName) {
1116
1137
1117
1138
try {
1118
1139
IMakeTargetManager targetManager = MakeCorePlugin .getDefault ().getTargetManager ();
1119
- IContainer targetResource = myProject .getFolder ("Release" ); //$NON-NLS-1$
1140
+ IContainer targetResource = myProject .getFolder (RELEASE );
1120
1141
IMakeTarget target = targetManager .findTarget (targetResource , targetName );
1121
1142
if (target == null ) {
1122
1143
target = targetManager .createTarget (myProject , targetName , "org.eclipse.cdt.build.MakeTargetBuilder" ); //$NON-NLS-1$
0 commit comments