2
0

_scala 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. #compdef scala scalac
  2. # ------------------------------------------------------------------------------
  3. # Copyright (c) 2012 GitHub zsh-users - https://github.com/zsh-users
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. # * Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # * Neither the name of the zsh-users nor the
  14. # names of its contributors may be used to endorse or promote products
  15. # derived from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
  21. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. # ------------------------------------------------------------------------------
  28. # Description
  29. # -----------
  30. #
  31. # Completion script for scala and scalac (https://www.scala-lang.org/).
  32. #
  33. # ------------------------------------------------------------------------------
  34. # Authors
  35. # -------
  36. #
  37. # * Tony Sloane <inkytonik@gmail.com>
  38. #
  39. # ------------------------------------------------------------------------------
  40. typeset -A opt_args
  41. local context state line
  42. _scala_features () {
  43. compadd "postfixOps" "reflectiveCalls" "implicitConversions" "higherKinds" \
  44. "existentials" "experimental.macros" "_"
  45. }
  46. _scala_phases () {
  47. compadd "parser" "namer" "packageobjects" "typer" "patmat" "superaccessors" \
  48. "extmethods" "pickler" "refchecks" "selectiveanf" "selectivecps" "uncurry" \
  49. "tailcalls" "specialize" "explicitouter" "erasure" "posterasure" "lazyvals" \
  50. "lambdalift" "constructors" "flatten" "mixin" "cleanup" "icode" "inliner" \
  51. "inlineExceptionHandlers" "closelim" "dce" "jvm" "terminal"
  52. }
  53. local -a shared_opts
  54. shared_opts=(
  55. "-bootclasspath+[Override location of bootstrap class files]:bootstrap class directory:_files -/"
  56. "-classpath+[Specify where to find user class files]:directory:_files -/"
  57. "-D-[Pass -Dproperty=value directly to the runtime system]"
  58. "-d+[Destination for generated classfiles]: directory or jar file:_files"
  59. "-dependencyfile+[Set dependency tracking file]:dependency tracking file:_files"
  60. "-deprecation[Emit warning and location for usages of deprecated APIs]"
  61. "-encoding+[Specify character encoding used by source files]:encoding:"
  62. "-explaintypes[Explain type errors in more detail]"
  63. "-extdirs+[Override location of installed extensions]:extensions directory:_files -/"
  64. "-g\:-[Set level of generated debugging info (default\: vars)]:debugging info level:(none source line vars notailcalls)"
  65. "-help[Print a synopsis of standard options]"
  66. "-J-[pass argument directly to Java runtime system]:JVM argument:"
  67. "-javabootclasspath+[Override java boot classpath]:Java boot class path directory]:_files -/"
  68. "-javaextdirs+[Override java extdirs classpath]:Java extdirs directory:_files -/"
  69. "-language\:-[Enable one or more language features]:feature:_scala_features"
  70. "-no-specialization[Ignore @specialize annotations]"
  71. "-nobootcp[Do not use the boot classpath for the scala jars]"
  72. "-nowarn[Generate no warnings]"
  73. "-optimise[Generate faster bytecode by applying optimisations to the program]"
  74. "-P\:-[Pass an option to a plugin (written plugin\:opt)]:plugin option:"
  75. "-print[Print program with Scala-specific features removed]"
  76. "-sourcepath+[Specify location(s) of source files]:source file directory:_files -/"
  77. "-target\:-[Target platform for object files (default\: jvm-1.5)]:platform name:(jvm-1.5 msil)"
  78. "-toolcp+[Add to the runner classpath]:directory:_files -/"
  79. "-unchecked[Enable detailed unchecked (erasure) warnings]"
  80. "-uniqid[Uniquely tag all identifiers in debugging output]"
  81. "-usejavacp[Utilize the java.class.path in classpath resolution]"
  82. "-verbose[Output messages about what the compiler is doing]"
  83. "-version[Print product version and exit]"
  84. "-X[Print a synopsis of advanced options]"
  85. "-Y[Print a synopsis of private options]"
  86. )
  87. local -a X_opts
  88. X_opts=(
  89. "-Xcheck-null[Warn upon selection of nullable reference]"
  90. "-Xcheckinit[Wrap field accessors to throw an exception on uninitialized access]"
  91. "-Xdisable-assertions[Generate no assertions or assumptions]"
  92. "-Xelide-below+[Calls to @elidable methods are omitted if method priority is lower than integer argument]"
  93. "-Xexperimental[Enable experimental extensions]"
  94. "-Xfatal-warnings[Fail the compilation if there are any warnings]"
  95. "-Xfull-lubs[Retains pre 2.10 behavior of less aggressive truncation of least upper bounds]"
  96. "-Xfuture[Turn on future language features]"
  97. "-Xgenerate-phase-graph+[Generate the phase graphs (outputs .dot files) to fileX.dot]:output file:_files"
  98. "-Xlint[Enable recommended additional warnings]"
  99. "-Xlog-free-terms[Print a message when reification creates a free term]"
  100. "-Xlog-free-types[Print a message when reification resorts to generating a free type]"
  101. "-Xlog-implicits[Show more detail on why some implicits are not applicable]"
  102. "-Xlog-implicit-conversions[Print a message whenever an implicit conversion is inserted]"
  103. "-Xlog-reflective-calls[Print a message when a reflective method call is generated]"
  104. "-Xmacro-settings\:-[Custom settings for macros]:option"
  105. "-Xmain-class+[Class for manifest's Main-Class entry (only useful with -d jar)]:path:"
  106. "-Xmax-classfile-name+[Maximum filename length for generated classes]"
  107. "-Xmigration[Warn about constructs whose behavior may have changed]"
  108. "-Xno-forwarders[Do not generate static forwarders in mirror classes]"
  109. "-Xno-patmat-analysis[Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation]"
  110. "-Xno-uescape[Disable handling of \u unicode escapes]"
  111. "-Xnojline[Do not use JLine for editing]"
  112. "-Xoldpatmat[Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10]"
  113. "-Xprint\:-[Print out program after <phase>]:phase name:_scala_phases"
  114. "-Xprint-icode\:-[Log internal icode to *.icode files after phase (default\: icode)]:phase name:_scala_phases"
  115. "-Xprint-pos[Print tree positions, as offsets]"
  116. "-Xprint-types[Print tree types (debugging option)]"
  117. "-Xprompt[Display a prompt after each error (debugging option)]"
  118. "-Xresident[Compiler stays resident: read source filenames from standard input]"
  119. "-Xscript+[Treat the source file as a script and wrap it in a main method]:main object name"
  120. "-Xshow-class+[Show internal representation of class]:class name"
  121. "-Xshow-object+[Show internal representation of object]:object name"
  122. "-Xshow-phases[Print a synopsis of compiler phases]"
  123. "-Xsource-reader+[Specify a class name for a custom method of reading source files]:class name"
  124. "-Xverify[Verify generic signatures in generated bytecode]"
  125. "-Xassem-extdirs+[List of directories containing assemblies (requires -target:msil) (default\: lib)]:assembly directory:_files -/"
  126. "-Xassem-name+[Name of the output assembly (requires -target:msil)]:assembly name:_files"
  127. "-Xassem-path+[List of assemblies referenced by the program (requires -target:msil)]:assembly path:_files"
  128. "-Xsourcedir+[Mirror source folder structure in output directory (requires -target:msil)]:source directory:_files -/"
  129. "-Xplugin\:-[Load one or more plugins from file]:plugin file:_files"
  130. "-Xpluginsdir+[Path to search compiler plugins]:plugin directory:_files -/"
  131. "-Xplugin-list[Print a synopsis of loaded plugins]"
  132. "-Xplugin-disable\:-[Disable the given plugin(s)]"
  133. "-Xplugin-require\:-[Abort unless the given plugin(s) are available]"
  134. )
  135. local -a Y_opts
  136. Y_opts=(
  137. "-Y[Print a synopsis of private options]"
  138. "-Ybuild-manager-debug[Generate debug information for the Refined Build Manager compiler]"
  139. "-Ybuilder-debug\:-[Compile using the specified build manager (default\: none)]:build manager:(none refined simple)"
  140. "-Yclosure-elim[Perform closure elimination]"
  141. "-Ycompact-trees[Use compact tree printer when displaying trees]"
  142. "-Ydead-code[Perform dead code elimination]"
  143. "-Ydependent-method-types[Allow dependent method types]"
  144. "-Ydump-classes+[Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders)]:output directory:_files -/"
  145. "-Yeta-expand-keeps-star[Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.]"
  146. "-Ygen-javap+[Generate a parallel output directory of .javap files]:output directory:_files -/"
  147. "-Yinfer-argument-types[Infer types for arguments of overridden methods]"
  148. "-Yinline[Perform inlining when possible]"
  149. "-Yinline-handlers[Perform exception handler inlining when possible]"
  150. "-Yinline-warnings[Emit inlining warnings (normally suppressed due to high volume)]"
  151. "-Yinvalidate+[Invalidate classpath entry before run]:classpath entry"
  152. "-Ylinearizer\:-[Linearizer to use (default\: rpo)]:linearizer:(normal dfs rpo dump)"
  153. "-Ylog-classpath[Output information about what classpath is being applied]"
  154. "-Yno-adapted-args[Do not adapt an argument list (either by inserting unit or creating a tuple) to match the receiver]"
  155. "-Ymacro-debug-lite[Trace essential macro-related activities]"
  156. "-Ymacro-debug-verbose[Trace all macro-related activities: compilation, generation of synthetics, classloading, expansion, exceptions]"
  157. "-Yno-completion[Disable tab-completion in the REPL]"
  158. "-Yno-generic-signatures[Suppress generation of generic signatures for Java]"
  159. "-Yno-imports[Compile without any implicit imports]"
  160. "-Yno-predef[Compile without importing Predef]"
  161. "-Yno-self-type-checks[Suppress check for self-type conformance among inherited members]"
  162. "-Yno-squeeze[Disable creation of compact code in matching]"
  163. "-Ynotnull[Enable (experimental and incomplete) scala.NotNull]"
  164. "-Yoverride-objects[Allow member objects to be overridden]"
  165. "-Yoverride-vars[Allow vars to be overridden]"
  166. "-Ypmat-naive[Desugar matches as naively as possible]"
  167. "-Ypresentation-delay+[Wait number of ms after typing before starting typechecking]"
  168. "-Ypresentation-log+[Log presentation compiler events into file]:log file:_files"
  169. "-Ypresentation-replay+[Replay presentation compiler events from file]:log file:_files"
  170. "-Ypresentation-strict[Do not report type errors in sources with syntax errors]"
  171. "-Ypresentation-verbose[Print information about presentation compiler tasks]"
  172. "-Yprofile-class+[Specify name of profiler class]:profiler class name"
  173. "-Yprofile-memory[Heap snapshot after compiler run (requires jgpagent on JVM -agentpath)]"
  174. "-Yrangepos[Use range positions for syntax trees]"
  175. "-Yrecursion+[Set recursion depth used when locking symbols]"
  176. "-Yreify-copypaste[Dump the reified trees in copypasteable representation]"
  177. "-Yrepl-sync[Do not use asynchronous code for REPL startup]"
  178. "-Yresolve-term-conflict\:-[Resolve term conflicts (default\: error)]:resolution strategy:(package object error)"
  179. "-Yself-in-annots[Include a \"self\" identifier inside of annotations]"
  180. "-Yshow\:-[Show after <phase> (requires -Xshow-class or -Xshow-object)]:phase name:_scala_phases"
  181. "-Yshow-syms[Print the AST symbol hierarchy after each phase]"
  182. "-Yshow-symkinds[Print abbreviated symbol kinds next to symbol names]"
  183. "-Yshow-trees[Print detailed ASTs (requires -Xprint\:phase)]"
  184. "-Yshow-trees-compact[Print detailed ASTs in compact form (requires -Xprint\:)]"
  185. "-Yshow-trees-stringified[Print stringification along with detailed ASTs (requires -Xprint\:)]"
  186. "-Ystatistics[Print compiler statistics]"
  187. "-Ystruct-dispatch\:-[Structural method dispatch policy (default\: poly-cache)]:policy name:(no-cache mono-cache poly-cache invoke-dynamic)"
  188. "-Ybrowse\:-[Browse the abstract syntax tree after <phase>]:phase name:_scala_phases"
  189. "-Ycheck\:-[Check the tree at the end of <phase>]:phase name:_scala_phases"
  190. "-Ylog\:-[Log operations during <phase>]:phase name:_scala_phases"
  191. "-Yprofile\:-[Profile CPU usage of given phases (requires jgpagent on JVM -agentpath)]:phase name:_scala_phases"
  192. "-Yskip\:-[Skip <phase>]:phase name:_scala_phases"
  193. "-Ystop-after\:-[Stop after given phase <phase>]:phase name:_scala_phases"
  194. "-Ystop-before\:-[Stop before given phase <phase>]:phase name:_scala_phases"
  195. "-Ywarn-adapted-args[Warn if an argument list is modified to match the receiver]"
  196. "-Ywarn-all[Enable all -Y warnings]"
  197. "-Ywarn-dead-code[Warn when dead code is identified]"
  198. "-Ywarn-inaccessible[Warn about inaccessible types in method signatures]"
  199. "-Ywarn-nullary-override[Warn when non-nullary overrides nullary, e.g. def foo() over def foo]"
  200. "-Ywarn-nullary-unit[Warn when nullary methods return Unit]"
  201. "-Ywarn-numeric-widen[Warn when numerics are widened]"
  202. "-Ywarn-value-discard[Warn when non-Unit expression results are unused]"
  203. "-Ybuild-manager-debug[Generate debug information for the Refined Build Manager compiler]"
  204. "-Ybuilder-debug\:-[Compile using the specified build manager (default\: none)]:manager:(none refined simple)"
  205. "-Ycompletion-debug[Trace all tab completion activity]"
  206. "-Ydebug[Increase the quantity of debugging output]"
  207. "-Ydoc-debug[Trace all scaladoc activity]"
  208. "-Yide-debug[Generate, validate and output trees using the interactive compiler]"
  209. "-Yinfer-debug[Trace type inference and implicit search]"
  210. "-Yissue-debug[Print stack traces when a context issues an error]"
  211. "-Ypatmat-debug[Trace pattern matching translation]"
  212. "-Ypmat-debug[Trace all pattern matcher activity]"
  213. "-Ypos-debug[Trace position validation]"
  214. "-Ypresentation-debug[Enable debugging output for the presentation compiler]"
  215. "-Yreify-debug[Trace reification]"
  216. "-Yrepl-debug[Trace all REPL activity]"
  217. "-Ytyper-debug[Trace all type assignments]"
  218. )
  219. local -a scala_opts
  220. scala_opts=(
  221. "-e+[execute <string> as if entered in the repl]:string" \
  222. "-howtorun+[what to run (default\: guess)]:execution mode:(script object jar guess)" \
  223. "-i+[preload <file> before starting the repl]:file to preload:_files" \
  224. "-nc[no compilation daemon\: do not use the fsc offline compiler]" \
  225. "-save[save the compiled script in a jar for future use]"
  226. )
  227. case $words[$CURRENT] in
  228. -X*) _arguments $X_opts;;
  229. -Y*) _arguments $Y_opts;;
  230. *) case $service in
  231. scala) _arguments $scala_opts $shared_opts "*::filename:_files";;
  232. scalac) _arguments $shared_opts "*::filename:_files";;
  233. esac
  234. esac
  235. return 0