Created
May 8, 2013 00:11
-
-
Save joshknutson/5537234 to your computer and use it in GitHub Desktop.
eclipse to sublime snippet converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif getValue('sublime_snippet_directory') neq "" and getValue("eclipse_snippet_directory") neq ""> | |
<cfset sublime_snippet_directory = getValue('sublime_snippet_directory') /> | |
<cfset eclipse_snippet_directory = getValue("eclipse_snippet_directory") /> | |
<cfset snips = [] /> | |
<cfset f = (eclipse_snippet_directory&"\keyCombos.properties") /> | |
<cfloop file="#f#" index="i"> | |
<cfif find('=',i)> | |
<cfset shortcut = listfirst(i,"=") /> | |
<cfset file_name = listlast(i,"/") /> | |
<cfset file_name = replace(file_name,".xml",".sublime-snippet") /> | |
<cfset path = eclipse_snippet_directory&listlast(i,'=') /> | |
<cfif fileExists(path)> | |
<cfset theFile = fileread(path) /> | |
<!--- read in shortcut keys and file location ---> | |
<cfset t = replace(theFile,'<%cf','<cf','all') /> | |
<cfset old = xmlparse(trim(t)) /> | |
<cfset content = old.snippet.starttext.xmlcdata /> | |
<cfset c = rematch('\$\$\{',content) /> | |
<cfset q = rematch('\$\${.*?}',content) /> | |
<cfset temp = structNew()> | |
<cfloop array="#(q)#" index="j"> | |
<cfset temp[j] = ""> | |
</cfloop> | |
<cfset c = listtoarray(structKeyList(temp,"::"),"::")> | |
<cfloop from="1" to="#arraylen(c)#" index="j"> | |
<cfset item = c[j] /> | |
<cfset flip = replace(c[j],'$${','${#j#:','all') /> | |
<cfset content = replace(content,item,flip,'all') /> | |
</cfloop> | |
<cfoutput> | |
<cfsavecontent variable="snip"> | |
<snippet> | |
<content><![CDATA[#content#$0#old.snippet.endtext.xmlcdata#]]></content> | |
<tabTrigger>#shortcut#</tabTrigger> | |
<!--- <scope>source.cfm,source.cfc</scope> ---> | |
<description>#old.snippet.name.xmltext#</description> | |
</snippet> | |
</cfsavecontent> | |
</cfoutput> | |
<cfset fileWrite('C:\workspace\_programs\Sublime Text 2\Data\Packages\Coldfusion\snippets\minerva\#file_name#',trim(snip)) /> | |
<cfset arrayappend(snips,trim(snip)) /> | |
</cfif> | |
</cfif> | |
</cfloop> | |
Snippets created, did it work? | |
<cfabort /> | |
</cfif> | |
<form> | |
<label for="eclipse_snippet_directory">eclipse snippet directory</label> | |
<input type="text" name="eclipse_snippet_directory" id="eclipse_snippet_directory" value="C:\workspace\minerva\documents\snippets" /> | |
<br /><label for="sublime_snippet_directory">sublime snippet directory</label> | |
<input type="text" name="sublime_snippet_directory" value="C:\workspace\_programs\Sublime Text 2\Data\Packages\Coldfusion\snippets\minerva\" /> | |
<br /><input type="submit" value="create snippets" /> | |
</form> | |
<cffunction name="getValue" access="public" output="false" returntype="any"> | |
<cfargument name="v" required="true" /> | |
<cfargument name="default" required="false" default="" /> | |
<cfset var local = {} /> | |
<cfloop list="form,url" index="local.i"> | |
<cfif structKeyExists(evaluate(local.i),arguments.v) and #evaluate(local.i)[arguments.v]# neq ""> | |
<cfreturn evaluate(local.i)[arguments.v] /> | |
</cfif> | |
</cfloop> | |
<cfreturn arguments.default /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment