home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 March / Macworld (1998-03) (Disk 1).dmg / Shareware World / Utilities / Text Processing / Alpha / Tcl / Completions / JavaCompletions.tcl < prev    next >
Encoding:
Text File  |  1997-10-08  |  2.6 KB  |  64 lines  |  [TEXT/ALFA]

  1. ## 
  2.  # This    file will be sourced automatically, immediately after 
  3.  # the _first_ time    the    file which defines its mode is sourced.
  4.  # Use this file to declare completion items and procedures
  5.  # for this mode.
  6.  # 
  7.  # Some common defaults are included below.
  8.  ##
  9.  
  10. ## 
  11.  # These declare, in order,    the    names of the completion
  12.  # procedures for this mode.  The actual procedure
  13.  # must    be named '${mode}Completion::${listItem}', unless
  14.  # the item    is 'completion::*' in which case that actual
  15.  # procedure is    called.  The procedure 'modeALike' will
  16.  # map modes to similar modes so procs don't need to be
  17.  # repeated.  However each mode requires its own array entry
  18.  # here.
  19.  ##
  20. set completions(Java) {completion::cmd completion::electric Class completion::word}
  21.  
  22. # Declare some items to add to the elec menu
  23. lunion "JavaTemplates" createNewClass newFunction
  24.  
  25. # ◊◊◊◊ Completions ◊◊◊◊ #
  26.  
  27. set Javacmds { 
  28.     abstract boolean break byvalue catch class const continue 
  29.     default double extends false final finally float future generic 
  30.     implements import inner instanceof interface native operator outer 
  31.     package private protected public return short static super switch 
  32.     synchronized throw throws transient volatile while
  33. }
  34.  
  35. # NOTE FROM VINCE: I just copied these from C++ mode, I'm not sure if
  36. # some ought to be a bit different for Java.
  37. set Javaelectrics(for) " (•init•;•test•;•increment•)\{\n\t•loop body•\n\}\n••"
  38. set Javaelectrics(while) " (•test•)\{\n\t•loop body•\n\}\n••"
  39. set Javaelectrics(switch) " (•value•)\{\n…case •item•:\n\t•case body•\n…default:\n\t•default body•\n\}\n••"
  40. set Javaelectrics(case) " •item•:\n…•case body•\ncase"
  41. set Javaelectrics(do) " \{••\n\t••\n\} while (•test•);\n••"
  42. set Javaelectrics(if) "(•condition•)\{\n\t•if body•\n\} ••"
  43. set Javaelectrics(else) " \{\n\t•else body•\n\} ••"
  44. set Javaelectrics(class) " •object name• extends •super-class name• implements •interface-names• \{\n…public:\n\t•object name•(•args•);\n\n\};\n••"
  45. set Javaelectrics(try) " \{\r\t•try body•\r\}\rcatch (•...•) \{\r\t•catch body•\r\}\r••"
  46.  
  47. ## 
  48.  # -------------------------------------------------------------------------
  49.  # 
  50.  # "Java::Completion::Class" --
  51.  # 
  52.  #  If we've just typed the name of a class, struct or union, we can
  53.  #  automatically fill in all occurrences of that name in the rest of
  54.  #  the class.  (e.g. in constructors, destructors etc.)
  55.  # -------------------------------------------------------------------------
  56.  ##
  57. proc Java::Completion::Class { {cmd ""}} {
  58.     set cl [completion::lastTwoWords prev]
  59.     if {[lsearch "class struct union" [string trim $prev]] == -1} {
  60.         return 0
  61.     }
  62.     if [ring::type] {ring::replaceStopMatches "object name" $cl}
  63. }
  64.