|
From: <caw...@us...> - 2007-08-21 18:21:54
|
Revision: 3028
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3028&view=rev
Author: cawilliams
Date: 2007-08-21 11:21:51 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5626 - Add quick fix for method/local naming convention (and move common code to convert camelCase to under_scores into Util class).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java 2007-08-21 18:21:47 UTC (rev 3027)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java 2007-08-21 18:21:51 UTC (rev 3028)
@@ -206,4 +206,23 @@
return contents;
}
+
+ public static String camelCaseToUnderscores(String name) {
+ if (name == null) return null;
+ if (name.length() == 0) return "";
+ StringBuffer newName = new StringBuffer();
+ boolean lastWasUpper = false;
+ for (int i = 0; i < name.length(); i++) {
+ char c = name.charAt(i);
+ newName.append(Character.toLowerCase(c));
+ if (lastWasUpper && Character.isLowerCase(c)) {
+ if (newName.length() > 2) newName.insert(newName.length() - 2, "_");
+ lastWasUpper = false;
+ }
+ if (Character.isUpperCase(c)) {
+ lastWasUpper = true;
+ }
+ }
+ return newName.toString();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|