# Encoding: UTF-8

[{beforeRunningCommand: "saveActiveFile",
  command: "javamate_bootstrap.sh",
  input: "document",
  keyEquivalent: "@r",
  name: "Compile & Run",
  output: "showAsHTML",
  scope: "source.java",
  uuid: "752A2A98-EB02-4A4D-A3D4-522485DBF491"},
 {beforeRunningCommand: "saveActiveFile",
  command: "TM_JAVAMATE_GET_ARGS=1 javamate_bootstrap.sh",
  input: "document",
  keyEquivalent: "~@r",
  name: "Compile & Run (with args)",
  output: "showAsHTML",
  scope: "source.java",
  uuid: "4BC99514-9BF7-4F4F-BD84-7AD07EB81AC3"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby -w\n# Copies the fully qualified class name to the paste/clip board.\n# Used to add the class as an import.\n#\n\npackage, class_name = nil, nil\nSTDIN.each do |line|\n  if line =~ /\\s*package ([^;]+);/\n    package = $1\n  elsif !(line =~ /^\\s*\\/\\*/) && line =~ /\\b(?:class|interface)\\b ([A-Z][^ ]+) /\n    class_name = $1\n  end\n  \n  break if package && class_name\nend\n\nif package && class_name\n  name = \"\#{package}.\#{class_name}\"\n  IO.popen(\"pbcopy\", \"w\") { |pb| pb.print name}\n  puts \"Copied '\#{name}'\"\nelse\n  puts 'Package and class name not found.  Aborting.'\nend\n",
  input: "document",
  keyEquivalent: "@C",
  name: "Copy Fully Qualified Class Name",
  output: "showAsTooltip",
  scope: "source.java",
  uuid: "BED53D9E-7A4D-42A7-8A3F-E633973A6D14"},
 {beforeRunningCommand: "nop",
  command: 
   "echo \"<!-- gotAPI.com search widget v2 begin -->\n<body onload=\\\"init();\\\">\n<DIV>\n<STYLE>\n.gaMenu{border:1px solid #505050;background-color:#FAFAFA;padding:0px 5px 0px 5px;}\n.gaHeaderRow{font:bold 8pt Arial;color:#359155;border-top:1px solid #C0C0C0;width:250px;}\n.gaRegularRow,.gaFooterRow{font:8pt Arial;cursor:pointer;}\n.gaSelectedRow{font:8pt Arial;background-color:#c1e0e6;cursor:pointer;}\n</STYLE>\n<SCRIPT><!--\ngaMod='module_java15noui.js';gaTitle='J2SE v1.5 less UI';updateWhenLoaded=false;\nvar gaL=false;function gaInit(){if(gaL)return;gaL=true;var s=document.createElement('script');\ns.type='text/javascript';s.src='http://www.gotapi.com/widgets/compiled/c1_module_java15noui.js.jsz';s.defer='defer';s.defered='yes';\ndocument.getElementById('gaInfo').parentNode.appendChild(s)}function gaSearching(){\ndocument.getElementById('gaWait').style.display='';updateWhenLoaded=true;\ndocument.getElementById('gaInfo').style.display='none'}\n//-->\n</SCRIPT>\n<DIV style='font:bold 10pt Arial'>Quick J2SE v1.5 less UI lookup</DIV>\n<INPUT id=gaSearch size=20 onfocus=\\\"gaInit()\\\" onkeydown=\\\"gaSearching()\\\">\n<DIV id=gaInfo style='font:7pt Arial'>powered by <A href='http://www.gotapi.com' style='padding:0px'>gotAPI.com</A></DIV>\n<DIV id=gaWait style='font:7pt Arial;display:none'>Searching...</DIV>\n</DIV>\n</body>\n<!-- gotAPI.com search widget v2 end -->\"\n\nif [ $TM_CURRENT_WORD ] \nthen\n\techo \"<script>function init() { document.getElementById('gaSearch').value = '$TM_CURRENT_WORD'; document.getElementById('gaSearch').focus(); gaSearching(); }</script>\"\nfi",
  input: "none",
  keyEquivalent: "^h",
  name: "Documentation For Word",
  output: "showAsHTML",
  scope: "source.java",
  uuid: "CE007C8C-9A0B-43B8-AEAF-45613BCD3DF7"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby -w\n#\n# WARNING: This script modifies the source of your file!!!  No one but\n# yourself is responsible for it losing code.\n#\n# Provides an Eclipse like Organize Imports except it can't\n# add imports.  It cleans up the list by filtering out unused\n# imports and alphabetizing the used.\n#\n# * alphabetizes imports placing java.* and javax.* before others.\n# * removes unused imports.\n# * maintains any \"package.*;\" imports and static imports\n# * supports class names starting with lowercase characters (legacy code)\n#\n\nrequire 'pp'\n\nbefore, imports, after, all = [], [], [], []\n\nSTDIN.each do |line|\n  all << line\n  \n  if line =~ /\\s*^import /\n    imports << line.strip\n  elsif imports.empty? && (before.empty? || !before.last.strip.empty?)\n    before << line\n  elsif !imports.empty? && after.empty?\n    # remove empty lines after the imports and before anything else\n    after << line unless line.strip.empty?\n  elsif\n    after << line\n  end\nend\n\nif imports.empty?\n  # if there are no imports just output the original lines and exit\n  all.each { |line| puts line }\n  exit 0\nend\n\nclasses = {}\nimports.each do |import|\n  import.scan(/\\s*import\\s+([A-Za-z0-9.]+)\\.([a-zA-Z0-9]+);/) do |package, name|\n    classes[name] = { :package => package }\n  end\nend\n\nafter.each do |line|\n  next if line =~ %r{^\\s*(//|/\\*|\\*)} #comments\n  \n  # Attempt to find all classes in the file.  This is loose in that it\n  # accepts words with lowercase letters and identifies them as classes.  This is OK\n  # since it won't add imports, it's only used to determine if an existing import\n  # is valid.\n  line.scan(/\\b([A-Za-z]\\w*)(\\b|\\.)/) do |name, boundary|\n    classes[name][:used] = 1 if classes[name]\n  end\nend\n\n# Based upon the classes found in the file determine the used imports\njava_imports, other_imports = [], []\nclasses.each_pair do |name, info|\n  if info[:used]\n    array = (info[:package] =~ /^java[x]?\\./) ? java_imports : other_imports\n    array << \"import \#{info[:package]}.\#{name};\"\n  end\nend\n\n# Include any .* imports and static imports since they can't be validated\nimports.each do |import|\n  if import =~ /\\.\\*\\s*;/ || import =~ /^import static /\n    array = (import =~ / java[x]?\\./) ? java_imports : other_imports\n    array << import\n  end\nend\n\n# create section comprised of the import lines attempting to remove duplicate empty lines\nlast_was_empty, import_lines = before.last.strip.empty?, []\n[[\"\"], java_imports.sort, [\"\"], other_imports.sort, [\"\"]].flatten.each do |line|\n  # prevent multiple empty lines\n  next if last_was_empty && line.strip.empty? \n\n  last_was_empty = line.strip.empty? \n  import_lines << line\nend\n\n[before, import_lines, after].flatten.each do |line|\n  puts line\nend\n",
  input: "selection",
  keyEquivalent: "@O",
  name: "Organize Imports",
  output: "replaceSelectedText",
  scope: "source.java",
  uuid: "E330E2EF-0057-4920-9364-01604C67E664"}]
