Is there any possibility that i can search for a method in a class, trait or object via scala doc, globally? Example: I have a method name and I don't know which class it belongs to so i can type it in some scaladoc search and it will show me classes containing a method with the given name. (PS: i would have added the tag scaladoc, but apparently I'm unworthy...)
I don't think there is a general, built-in method. So if the scaladoc is online I use my friend Google. For instance to search for a method called left in the scala API, I use the query:
"def left" site:http://www.scala-lang.org/api/current/
If it's on my hard disk I use grep.
colladoc
The colladoc tool has a more useful search interface to the scaladocs than the standard scaladoc tool.
You can restrict the search to method names by prefixing the search string with "def", as in "def implicitly". If you click on the magnifying glass next to the search box, with an empty search string, you'll get the following handy list of sample queries:
any
searches for everything that has the word any in its name, definition or commentany_
searches for everything that starts with any//_any
searches for all comments that contain a word that ends with anyclass AnyRef
searches for all classes with name AnyReftrait _
searches for all traitsobject _
searches for all objectsclass A_ || class B_
searches for all classes that starts with A or Bclass _ extends _ with _
searches for all classes that extend a class and implement a traitvar _: Int
searches for all values or variables of type Int, vars are displayed before the valsdef toString
searches for all methods with name toStringdef toString : String
searches for all methods with name toString and return type Stringdef _(_) : Boolean
searches for all methods with one argument and returnType Booleandef _(Int, _)
searches for all methods with arguments and the first is of type Intdef _(_, *)
searches for all methods with one or more argumentsdef _(Iterable[_]):Int
searches for all methods that take an Iterable and return Int(Iterable[_]) => Int
equvalent to the above, lambda syntax can also be used for searching for methods.=> (_, _)
searches for all methods that return a tuple with two elements.def _((_) => _)
searches for all methods that have one as first parameter a method that takes and returns any value.
Unfortunately, colladoc's search results can be daunting. If a member exists in many traits/classes due to inheritance (e.g. the sum
method in the collections API), all of the classes are listed in the results.
scaladoc Alphabetical Index
There's no such search in scaladoc itself, but there is an alphabetic index that contains class/object/trait members. Just click on one of the letters below the search bar in the top left corner, and you'll see a list containing classes, objects, traits, and members starting with that letter (or symbols, if you click on the "#" link). Then you can use your browser's find function to look for the member you're interested in.
I use the alphabetic index in the top left under the search box. Would be nice if there were proper seach functionality though.
Would also be nice if the docs were available in Windows help format as they are for Java, which is much more convenient than the html javadoc, and lets you search on methods with almost zero latency.
© 2022 - 2024 — McMap. All rights reserved.