Skip to content

Commit 6603e84

Browse files
author
jantje
committed
Some more refactoring
The previous commits is one blop I split it into commits to have a functional overview of what changed but you probably need all of it.
1 parent 75e0ac4 commit 6603e84

File tree

6 files changed

+183
-191
lines changed

6 files changed

+183
-191
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import io.sloeber.common.Common;
4343
import io.sloeber.common.Const;
44+
import io.sloeber.core.Activator;
4445
import io.sloeber.core.InternalBoardDescriptor;
4546
import io.sloeber.core.tools.Helpers;
4647
import io.sloeber.core.tools.Programmers;
@@ -49,7 +50,7 @@
4950

5051
public class BoardDescriptor {
5152
// preference nodes
52-
public static final String NODE_ARDUINO = Const.PLUGIN_START + "arduino"; //$NON-NLS-1$
53+
public static final String NODE_ARDUINO = Activator.NODE_ARDUINO;
5354
/**
5455
*
5556
*/
@@ -101,7 +102,7 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
101102
} else {
102103
this.myUploadPort = Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_UPLOAD_PORT, "");
103104
this.myUploadProtocol = Common.getBuildEnvironmentVariable(confdesc,
104-
Const.get_Jantje_KEY_PROTOCOL(Const.ACTION_UPLOAD), "");
105+
Common.get_Jantje_KEY_PROTOCOL(Const.ACTION_UPLOAD), "");
105106
this.myBoardsFile = new File(
106107
Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_BOARDS_FILE, ""));
107108
this.myBoardID = Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_BOARD_ID, "");
@@ -256,7 +257,7 @@ public void save(ICConfigurationDescription confdesc) throws Exception {
256257
Common.setBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_ARCITECTURE_ID, getArchitecture());
257258
Common.setBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_PACKAGE_ID, getPackage());
258259
Common.setBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_UPLOAD_PORT, this.myUploadPort);
259-
Common.setBuildEnvironmentVariable(confdesc, Const.get_Jantje_KEY_PROTOCOL(Const.ACTION_UPLOAD),
260+
Common.setBuildEnvironmentVariable(confdesc, Common.get_Jantje_KEY_PROTOCOL(Const.ACTION_UPLOAD),
260261
this.myUploadProtocol);
261262
if (this.myOptions != null) {
262263
for (Map.Entry<String, String> curoption : this.myOptions.entrySet()) {

io.sloeber.core/src/io/sloeber/core/api/CodeDescriptor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum CodeTypes {
3232
private CodeTypes codeType;
3333
private IPath myTemPlateFoldername;
3434
private boolean myMakeLinks = false;
35-
private ArrayList<Path> myLastUsedExamples = new ArrayList<>();
35+
private ArrayList<Path> myExamples = new ArrayList<>();
3636

3737
public IPath getTemPlateFoldername() {
3838
return this.myTemPlateFoldername;
@@ -50,10 +50,10 @@ public static CodeDescriptor createDefaultCPP() {
5050
return new CodeDescriptor(CodeTypes.defaultCPP);
5151
}
5252

53-
public static CodeDescriptor createSample(boolean link, ArrayList<Path> sampleFolders) {
53+
public static CodeDescriptor createExample(boolean link, ArrayList<Path> sampleFolders) {
5454
CodeDescriptor codeDescriptor = new CodeDescriptor(CodeTypes.sample);
5555
codeDescriptor.myMakeLinks = link;
56-
codeDescriptor.myLastUsedExamples = sampleFolders;
56+
codeDescriptor.myExamples = sampleFolders;
5757
return codeDescriptor;
5858
}
5959

@@ -134,7 +134,7 @@ public void createFiles(IProject project, IProgressMonitor monitor) throws CoreE
134134
break;
135135
case sample:
136136
try {
137-
for (Path curPath : this.myLastUsedExamples) {
137+
for (Path curPath : this.myExamples) {
138138
if (this.myMakeLinks) {
139139
Helpers.linkDirectory(project, curPath, new Path("/"));
140140
} else {
@@ -157,17 +157,17 @@ private void loadLastUsedExamples() {
157157
.getGlobalString(Const.KEY_LAST_USED_EXAMPLES, Defaults.getPrivateLibraryPath()).split("\n");
158158

159159
for (String curpath : examplePathNames) {
160-
this.myLastUsedExamples.add(new Path(curpath));
160+
this.myExamples.add(new Path(curpath));
161161
}
162162
}
163163

164-
public ArrayList<Path> getLastUsedExamples() {
165-
return this.myLastUsedExamples;
164+
public ArrayList<Path> getExamples() {
165+
return this.myExamples;
166166
}
167167

168168
private void saveLastUsedExamples() {
169-
if (this.myLastUsedExamples != null) {
170-
String toStore = StringUtils.join(this.myLastUsedExamples, "\n"); //$NON-NLS-1$
169+
if (this.myExamples != null) {
170+
String toStore = StringUtils.join(this.myExamples, "\n"); //$NON-NLS-1$
171171
InstancePreferences.setGlobalValue(Const.KEY_LAST_USED_EXAMPLES, toStore);
172172
} else {
173173
InstancePreferences.setGlobalValue(Const.KEY_LAST_USED_EXAMPLES, Const.EMPTY_STRING);

io.sloeber.core/src/io/sloeber/core/api/CompileOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
88
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
99

10+
import io.sloeber.common.Common;
1011
import io.sloeber.common.Const;
1112

1213
public class CompileOptions {
@@ -115,7 +116,7 @@ public void save(ICConfigurationDescription configuration) {
115116
contribEnv.addVariable(var, configuration);
116117
} else {
117118
var = new EnvironmentVariable(Const.ENV_KEY_JANTJE_SIZE_SWITCH, "${" //$NON-NLS-1$
118-
+ Const.get_ENV_KEY_RECIPE(Const.ACTION_SIZE) + "}"); //$NON-NLS-1$
119+
+ Common.get_ENV_KEY_RECIPE(Const.ACTION_SIZE) + "}"); //$NON-NLS-1$
119120
contribEnv.addVariable(var, configuration);
120121
}
121122
var = new EnvironmentVariable(Const.ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS,

io.sloeber.core/src/io/sloeber/core/tools/Helpers.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,4 @@ public static void linkDirectory(IProject project, IPath source, IPath target) {
13711371

13721372
}
13731373

1374-
/**
1375-
* given a action and a tool return the environment key that matches it's
1376-
* recipe
1377-
*
1378-
* @param action
1379-
* @return he environment variable key to find the recipe
1380-
*/
1381-
private static String get_ENV_KEY_RECIPE(String tool, String action) {
1382-
return ERASE_START + "TOOLS" + DOT + tool.toUpperCase() + DOT + action.toUpperCase() + DOT + ENV_PATTERN; //$NON-NLS-1$
1383-
}
1384-
13851374
}

0 commit comments

Comments
 (0)