22
33import java .io .File ;
44import java .util .HashSet ;
5- import java .util .Vector ;
5+ import java .util .List ;
6+ import java .util .Set ;
67
78import org .eclipse .cdt .core .CCorePlugin ;
89import org .eclipse .cdt .core .envvar .EnvironmentVariable ;
@@ -37,16 +38,18 @@ public class Common extends InstancePreferences {
3738 // request him to disconnect
3839 // when we need the serial port
3940
41+ static Set <IProject > fProjects = new HashSet <>();
42+
4043 /**
4144 * This method is used to register a serial user. A serial user is alerted
4245 * when the serial port will be disconnected (for instance for a upload) The
4346 * serial user is requested to act appropriately Only 1 serial user can be
4447 * registered at a given time. No check is done.
4548 *
46- * @param SerialUser
49+ * @param serialUser
4750 */
48- public static void registerSerialUser (ISerialUser SerialUser ) {
49- OtherSerialUser = SerialUser ;
51+ public static void registerSerialUser (ISerialUser serialUser ) {
52+ OtherSerialUser = serialUser ;
5053 }
5154
5255 /**
@@ -85,14 +88,14 @@ public static void UnRegisterSerialUser() {
8588 * redirect input, allowed in Unix filenames, see Note 1 > greater than used
8689 * to redirect output, allowed in Unix filenames, see Note 1 . period or dot
8790 *
88- * @param Name
91+ * @param name
8992 * the string that needs to be checked
9093 * @return a name safe to create files or folders
9194 */
92- public static String MakeNameCompileSafe (String Name ) {
93- char badChars [] = { ' ' , '/' , '.' , '/' , ':' , ' ' , '\\' , '(' , ')' , '*' , '?' , '%' , '|' , '<' , '>' , ',' , '-' };
95+ public static String MakeNameCompileSafe (String name ) {
96+ char [] badChars = { ' ' , '/' , '.' , '/' , ':' , ' ' , '\\' , '(' , ')' , '*' , '?' , '%' , '|' , '<' , '>' , ',' , '-' };
9497
95- String ret = Name .trim ();
98+ String ret = name .trim ();
9699 for (char curchar : badChars ) {
97100 ret = ret .replace (curchar , '_' );
98101 }
@@ -105,39 +108,37 @@ public static String MakeNameCompileSafe(String Name) {
105108 * @param project
106109 * The project for which the property is needed
107110 *
108- * @param Tag
111+ * @param tag
109112 * The tag identifying the property to read
110113 * @return returns the property when found. When not found returns an empty
111114 * string
112115 */
113- public static String getPersistentProperty (IProject project , String Tag ) {
116+ public static String getPersistentProperty (IProject project , String tag ) {
114117 try {
115- String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , Tag ));
118+ String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , tag ));
116119 if (sret == null ) {
117- sret = project .getPersistentProperty (new QualifiedName (EMPTY_STRING , Tag )); // for
120+ sret = project .getPersistentProperty (new QualifiedName (EMPTY_STRING , tag )); // for
118121 // downwards
119122 // compatibility
120123 if (sret == null )
121124 sret = EMPTY_STRING ;
122125 }
123126 return sret ;
124127 } 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$
127129 return EMPTY_STRING ;
128130 }
129131 }
130132
131- public static int getPersistentPropertyInt (IProject project , String Tag , int defaultValue ) {
133+ public static int getPersistentPropertyInt (IProject project , String tag , int defaultValue ) {
132134 try {
133- String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , Tag ));
135+ String sret = project .getPersistentProperty (new QualifiedName (CORE_PLUGIN_ID , tag ));
134136 if (sret == null ) {
135137 return defaultValue ;
136138 }
137139 return Integer .parseInt (sret );
138140 } 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$
141142 return defaultValue ;
142143 }
143144 }
@@ -148,15 +149,15 @@ public static int getPersistentPropertyInt(IProject project, String Tag, int def
148149 * @param project
149150 * The project for which the property needs to be set
150151 *
151- * @param Tag
152+ * @param tag
152153 * The tag identifying the property to read
153154 * @return returns the property when found. When not found returns an empty
154155 * string
155156 */
156- public static void setPersistentProperty (IProject project , String Tag , String Value ) {
157+ public static void setPersistentProperty (IProject project , String tag , String value ) {
157158 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
160161 // downwards
161162 // compatibility
162163 } catch (CoreException e ) {
@@ -166,8 +167,8 @@ public static void setPersistentProperty(IProject project, String Tag, String Va
166167 }
167168 }
168169
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 ));
171172 }
172173
173174 /**
@@ -177,7 +178,7 @@ public static void setPersistentProperty(IProject project, String Tag, int Value
177178 * the status information to log
178179 */
179180 public static void log (IStatus status ) {
180- int style = StatusManager . LOG ;
181+ int style ;
181182
182183 if (status .getSeverity () == IStatus .ERROR ) {
183184 style = StatusManager .LOG | StatusManager .SHOW | StatusManager .BLOCK ;
@@ -209,20 +210,20 @@ public static String UploadPortPrefix() {
209210 /**
210211 * ToInt converts a string to a integer in a save way
211212 *
212- * @param Number
213+ * @param number
213214 * is a String that will be converted to an integer. Number can
214215 * be null or empty and can contain leading and trailing white
215216 * space
216217 * @return The integer value represented in the string based on parseInt
217218 * @see parseInt. After error checking and modifications parseInt is used
218219 * for the conversion
219220 **/
220- public static int ToInt (String Number ) {
221- if (Number == null )
221+ public static int ToInt (String number ) {
222+ if (number == null )
222223 return 0 ;
223- if (Number .isEmpty ())
224+ if (number .isEmpty ())
224225 return 0 ;
225- return Integer .parseInt (Number .trim ());
226+ return Integer .parseInt (number .trim ());
226227 }
227228
228229 public static IWorkbenchWindow getActiveWorkbenchWindow () {
@@ -237,8 +238,6 @@ public static IWorkbenchPage getActivePage() {
237238 return null ;
238239 }
239240
240- static HashSet <IProject > fProjects = new HashSet <>();
241-
242241 public static boolean StopSerialMonitor (String mComPort ) {
243242 if (OtherSerialUser != null ) {
244243 return OtherSerialUser .PauzePort (mComPort );
@@ -254,9 +253,9 @@ public static void StartSerialMonitor(String mComPort) {
254253 }
255254
256255 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 );
260259 return outgoing ;
261260 }
262261
@@ -294,16 +293,16 @@ public static String getLineEnding(int selectionIndex) {
294293 * the project that contains the environment variable
295294 * @param configName
296295 * the project configuration to use
297- * @param EnvName
296+ * @param envName
298297 * the key that describes the variable
299298 * @param defaultvalue
300299 * The return value if the variable is not found.
301300 * @return The expanded build environment variable
302301 */
303- static public String getBuildEnvironmentVariable (IProject project , String configName , String EnvName ,
302+ static public String getBuildEnvironmentVariable (IProject project , String configName , String envName ,
304303 String defaultvalue ) {
305304 ICProjectDescription prjDesc = CoreModel .getDefault ().getProjectDescription (project );
306- return getBuildEnvironmentVariable (prjDesc .getConfigurationByName (configName ), EnvName , defaultvalue );
305+ return getBuildEnvironmentVariable (prjDesc .getConfigurationByName (configName ), envName , defaultvalue );
307306 }
308307
309308 /**
@@ -314,15 +313,15 @@ static public String getBuildEnvironmentVariable(IProject project, String config
314313 * @param project
315314 * the project that contains the environment variable
316315 *
317- * @param EnvName
316+ * @param envName
318317 * the key that describes the variable
319318 * @param defaultvalue
320319 * The return value if the variable is not found.
321320 * @return The expanded build environment variable
322321 */
323- static public String getBuildEnvironmentVariable (IProject project , String EnvName , String defaultvalue ) {
322+ static public String getBuildEnvironmentVariable (IProject project , String envName , String defaultvalue ) {
324323 ICProjectDescription prjDesc = CoreModel .getDefault ().getProjectDescription (project );
325- return getBuildEnvironmentVariable (prjDesc .getDefaultSettingConfiguration (), EnvName , defaultvalue );
324+ return getBuildEnvironmentVariable (prjDesc .getDefaultSettingConfiguration (), envName , defaultvalue );
326325 }
327326
328327 /**
@@ -332,24 +331,24 @@ static public String getBuildEnvironmentVariable(IProject project, String EnvNam
332331 *
333332 * @param project
334333 * the project that contains the environment variable
335- * @param EnvName
334+ * @param envName
336335 * the key that describes the variable
337336 * @param defaultvalue
338337 * The return value if the variable is not found.
339338 * @return The expanded build environment variable
340339 */
341340 static public String getBuildEnvironmentVariable (ICConfigurationDescription configurationDescription ,
342- String EnvName , String defaultvalue ) {
341+ String envName , String defaultvalue ) {
343342
344- return getBuildEnvironmentVariable (configurationDescription , EnvName , defaultvalue , true );
343+ return getBuildEnvironmentVariable (configurationDescription , envName , defaultvalue , true );
345344 }
346345
347346 static public String getBuildEnvironmentVariable (ICConfigurationDescription configurationDescription ,
348- String EnvName , String defaultvalue , boolean expanded ) {
347+ String envName , String defaultvalue , boolean expanded ) {
349348
350349 IEnvironmentVariableManager envManager = CCorePlugin .getDefault ().getBuildEnvironmentManager ();
351350 try {
352- return envManager .getVariable (EnvName , configurationDescription , expanded ).getValue ();
351+ return envManager .getVariable (envName , configurationDescription , expanded ).getValue ();
353352 } catch (Exception e ) {// ignore all errors and return the default value
354353 }
355354 return defaultvalue ;
@@ -374,8 +373,7 @@ public static String getDefaultPrivateHardwarePath() {
374373
375374 public static File getWorkspaceRoot () {
376375 IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin .getWorkspace ().getRoot ();
377- File ret = myWorkspaceRoot .getLocation ().toFile ();
378- return ret ;
376+ return myWorkspaceRoot .getLocation ().toFile ();
379377 }
380378
381379 public static void setBuildEnvironmentVariable (IContributedEnvironment contribEnv ,
0 commit comments