2
2
3
3
import java .io .File ;
4
4
import java .util .HashSet ;
5
- import java .util .Vector ;
5
+ import java .util .List ;
6
+ import java .util .Set ;
6
7
7
8
import org .eclipse .cdt .core .CCorePlugin ;
8
9
import org .eclipse .cdt .core .envvar .EnvironmentVariable ;
@@ -37,16 +38,18 @@ public class Common extends InstancePreferences {
37
38
// request him to disconnect
38
39
// when we need the serial port
39
40
41
+ static Set <IProject > fProjects = new HashSet <>();
42
+
40
43
/**
41
44
* This method is used to register a serial user. A serial user is alerted
42
45
* when the serial port will be disconnected (for instance for a upload) The
43
46
* serial user is requested to act appropriately Only 1 serial user can be
44
47
* registered at a given time. No check is done.
45
48
*
46
- * @param SerialUser
49
+ * @param serialUser
47
50
*/
48
- public static void registerSerialUser (ISerialUser SerialUser ) {
49
- OtherSerialUser = SerialUser ;
51
+ public static void registerSerialUser (ISerialUser serialUser ) {
52
+ OtherSerialUser = serialUser ;
50
53
}
51
54
52
55
/**
@@ -85,14 +88,14 @@ public static void UnRegisterSerialUser() {
85
88
* redirect input, allowed in Unix filenames, see Note 1 > greater than used
86
89
* to redirect output, allowed in Unix filenames, see Note 1 . period or dot
87
90
*
88
- * @param Name
91
+ * @param name
89
92
* the string that needs to be checked
90
93
* @return a name safe to create files or folders
91
94
*/
92
- public static String MakeNameCompileSafe (String Name ) {
93
- char badChars [] = { ' ' , '/' , '.' , '/' , ':' , ' ' , '\\' , '(' , ')' , '*' , '?' , '%' , '|' , '<' , '>' , ',' , '-' };
95
+ public static String MakeNameCompileSafe (String name ) {
96
+ char [] badChars = { ' ' , '/' , '.' , '/' , ':' , ' ' , '\\' , '(' , ')' , '*' , '?' , '%' , '|' , '<' , '>' , ',' , '-' };
94
97
95
- String ret = Name .trim ();
98
+ String ret = name .trim ();
96
99
for (char curchar : badChars ) {
97
100
ret = ret .replace (curchar , '_' );
98
101
}
@@ -105,39 +108,37 @@ public static String MakeNameCompileSafe(String Name) {
105
108
* @param project
106
109
* The project for which the property is needed
107
110
*
108
- * @param Tag
111
+ * @param tag
109
112
* The tag identifying the property to read
110
113
* @return returns the property when found. When not found returns an empty
111
114
* string
112
115
*/
113
- public static String getPersistentProperty (IProject project , String Tag ) {
116
+ public static String getPersistentProperty (IProject project , String tag ) {
114
117
try {
115
- String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , Tag ));
118
+ String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , tag ));
116
119
if (sret == null ) {
117
- sret = project .getPersistentProperty (new QualifiedName (EMPTY_STRING , Tag )); // for
120
+ sret = project .getPersistentProperty (new QualifiedName (EMPTY_STRING , tag )); // for
118
121
// downwards
119
122
// compatibility
120
123
if (sret == null )
121
124
sret = EMPTY_STRING ;
122
125
}
123
126
return sret ;
124
127
} catch (CoreException e ) {
125
- log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "Failed to read persistent setting " + Tag , e )); //$NON-NLS-1$
126
- // e.printStackTrace();
128
+ log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "Failed to read persistent setting " + tag , e )); //$NON-NLS-1$
127
129
return EMPTY_STRING ;
128
130
}
129
131
}
130
132
131
- public static int getPersistentPropertyInt (IProject project , String Tag , int defaultValue ) {
133
+ public static int getPersistentPropertyInt (IProject project , String tag , int defaultValue ) {
132
134
try {
133
- String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , Tag ));
135
+ String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , tag ));
134
136
if (sret == null ) {
135
137
return defaultValue ;
136
138
}
137
139
return Integer .parseInt (sret );
138
140
} catch (CoreException e ) {
139
- log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "Failed to read persistent setting " + Tag , e )); //$NON-NLS-1$
140
- // e.printStackTrace();
141
+ log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "Failed to read persistent setting " + tag , e )); //$NON-NLS-1$
141
142
return defaultValue ;
142
143
}
143
144
}
@@ -148,15 +149,15 @@ public static int getPersistentPropertyInt(IProject project, String Tag, int def
148
149
* @param project
149
150
* The project for which the property needs to be set
150
151
*
151
- * @param Tag
152
+ * @param tag
152
153
* The tag identifying the property to read
153
154
* @return returns the property when found. When not found returns an empty
154
155
* string
155
156
*/
156
- public static void setPersistentProperty (IProject project , String Tag , String Value ) {
157
+ public static void setPersistentProperty (IProject project , String tag , String value ) {
157
158
try {
158
- project .setPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , Tag ), Value );
159
- project .setPersistentProperty (new QualifiedName (EMPTY_STRING , Tag ), Value ); // for
159
+ project .setPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , tag ), value );
160
+ project .setPersistentProperty (new QualifiedName (EMPTY_STRING , tag ), value ); // for
160
161
// downwards
161
162
// compatibility
162
163
} catch (CoreException e ) {
@@ -166,8 +167,8 @@ public static void setPersistentProperty(IProject project, String Tag, String Va
166
167
}
167
168
}
168
169
169
- public static void setPersistentProperty (IProject project , String Tag , int Value ) {
170
- setPersistentProperty (project , Tag , Integer .toString (Value ));
170
+ public static void setPersistentProperty (IProject project , String tag , int value ) {
171
+ setPersistentProperty (project , tag , Integer .toString (value ));
171
172
}
172
173
173
174
/**
@@ -177,7 +178,7 @@ public static void setPersistentProperty(IProject project, String Tag, int Value
177
178
* the status information to log
178
179
*/
179
180
public static void log (IStatus status ) {
180
- int style = StatusManager . LOG ;
181
+ int style ;
181
182
182
183
if (status .getSeverity () == IStatus .ERROR ) {
183
184
style = StatusManager .LOG | StatusManager .SHOW | StatusManager .BLOCK ;
@@ -209,20 +210,20 @@ public static String UploadPortPrefix() {
209
210
/**
210
211
* ToInt converts a string to a integer in a save way
211
212
*
212
- * @param Number
213
+ * @param number
213
214
* is a String that will be converted to an integer. Number can
214
215
* be null or empty and can contain leading and trailing white
215
216
* space
216
217
* @return The integer value represented in the string based on parseInt
217
218
* @see parseInt. After error checking and modifications parseInt is used
218
219
* for the conversion
219
220
**/
220
- public static int ToInt (String Number ) {
221
- if (Number == null )
221
+ public static int ToInt (String number ) {
222
+ if (number == null )
222
223
return 0 ;
223
- if (Number .isEmpty ())
224
+ if (number .isEmpty ())
224
225
return 0 ;
225
- return Integer .parseInt (Number .trim ());
226
+ return Integer .parseInt (number .trim ());
226
227
}
227
228
228
229
public static IWorkbenchWindow getActiveWorkbenchWindow () {
@@ -237,8 +238,6 @@ public static IWorkbenchPage getActivePage() {
237
238
return null ;
238
239
}
239
240
240
- static HashSet <IProject > fProjects = new HashSet <>();
241
-
242
241
public static boolean StopSerialMonitor (String mComPort ) {
243
242
if (OtherSerialUser != null ) {
244
243
return OtherSerialUser .PauzePort (mComPort );
@@ -254,9 +253,9 @@ public static void StartSerialMonitor(String mComPort) {
254
253
}
255
254
256
255
public static String [] listComPorts () {
257
- Vector <String > SerialList = Serial .list ();
258
- String outgoing [] = new String [SerialList .size ()];
259
- SerialList . copyInto (outgoing );
256
+ List <String > serialList = Serial .list ();
257
+ String [] outgoing = new String [serialList .size ()];
258
+ serialList . toArray (outgoing );
260
259
return outgoing ;
261
260
}
262
261
@@ -294,16 +293,16 @@ public static String getLineEnding(int selectionIndex) {
294
293
* the project that contains the environment variable
295
294
* @param configName
296
295
* the project configuration to use
297
- * @param EnvName
296
+ * @param envName
298
297
* the key that describes the variable
299
298
* @param defaultvalue
300
299
* The return value if the variable is not found.
301
300
* @return The expanded build environment variable
302
301
*/
303
- static public String getBuildEnvironmentVariable (IProject project , String configName , String EnvName ,
302
+ static public String getBuildEnvironmentVariable (IProject project , String configName , String envName ,
304
303
String defaultvalue ) {
305
304
ICProjectDescription prjDesc = CoreModel .getDefault ().getProjectDescription (project );
306
- return getBuildEnvironmentVariable (prjDesc .getConfigurationByName (configName ), EnvName , defaultvalue );
305
+ return getBuildEnvironmentVariable (prjDesc .getConfigurationByName (configName ), envName , defaultvalue );
307
306
}
308
307
309
308
/**
@@ -314,15 +313,15 @@ static public String getBuildEnvironmentVariable(IProject project, String config
314
313
* @param project
315
314
* the project that contains the environment variable
316
315
*
317
- * @param EnvName
316
+ * @param envName
318
317
* the key that describes the variable
319
318
* @param defaultvalue
320
319
* The return value if the variable is not found.
321
320
* @return The expanded build environment variable
322
321
*/
323
- static public String getBuildEnvironmentVariable (IProject project , String EnvName , String defaultvalue ) {
322
+ static public String getBuildEnvironmentVariable (IProject project , String envName , String defaultvalue ) {
324
323
ICProjectDescription prjDesc = CoreModel .getDefault ().getProjectDescription (project );
325
- return getBuildEnvironmentVariable (prjDesc .getDefaultSettingConfiguration (), EnvName , defaultvalue );
324
+ return getBuildEnvironmentVariable (prjDesc .getDefaultSettingConfiguration (), envName , defaultvalue );
326
325
}
327
326
328
327
/**
@@ -332,24 +331,24 @@ static public String getBuildEnvironmentVariable(IProject project, String EnvNam
332
331
*
333
332
* @param project
334
333
* the project that contains the environment variable
335
- * @param EnvName
334
+ * @param envName
336
335
* the key that describes the variable
337
336
* @param defaultvalue
338
337
* The return value if the variable is not found.
339
338
* @return The expanded build environment variable
340
339
*/
341
340
static public String getBuildEnvironmentVariable (ICConfigurationDescription configurationDescription ,
342
- String EnvName , String defaultvalue ) {
341
+ String envName , String defaultvalue ) {
343
342
344
- return getBuildEnvironmentVariable (configurationDescription , EnvName , defaultvalue , true );
343
+ return getBuildEnvironmentVariable (configurationDescription , envName , defaultvalue , true );
345
344
}
346
345
347
346
static public String getBuildEnvironmentVariable (ICConfigurationDescription configurationDescription ,
348
- String EnvName , String defaultvalue , boolean expanded ) {
347
+ String envName , String defaultvalue , boolean expanded ) {
349
348
350
349
IEnvironmentVariableManager envManager = CCorePlugin .getDefault ().getBuildEnvironmentManager ();
351
350
try {
352
- return envManager .getVariable (EnvName , configurationDescription , expanded ).getValue ();
351
+ return envManager .getVariable (envName , configurationDescription , expanded ).getValue ();
353
352
} catch (Exception e ) {// ignore all errors and return the default value
354
353
}
355
354
return defaultvalue ;
@@ -374,8 +373,7 @@ public static String getDefaultPrivateHardwarePath() {
374
373
375
374
public static File getWorkspaceRoot () {
376
375
IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin .getWorkspace ().getRoot ();
377
- File ret = myWorkspaceRoot .getLocation ().toFile ();
378
- return ret ;
376
+ return myWorkspaceRoot .getLocation ().toFile ();
379
377
}
380
378
381
379
public static void setBuildEnvironmentVariable (IContributedEnvironment contribEnv ,
0 commit comments