7

I'm trying to find sample code examples that involve a certain package. If I can do so I can show where this particular packages was used previously by others.

Is there anyway to do this?

The Package in question is SwingBuilders which 'belongs' to JavaBuilders.

In short the question I want to answer, which projects have used the SwingBuilders package on GitHub?

  • Do the results from github.com/… provide a starting point on examples? – Eight Days of Malaise Jan 13 '14 at 4:22
  • Yes but I feel there're too many false positives – Pureferret Jan 14 '14 at 19:22
  • False positives as in those used on test and example code, instead of live use? – Eight Days of Malaise Jan 14 '14 at 21:12
  • @Eightdaysofmalaise no, matching a similarly named code in Groovy. I think the two can be used together. But you make a fair point about example vs live code – Pureferret Jan 14 '14 at 23:21
  • For just the Java, you can filter that github.com/… – Eight Days of Malaise Jan 15 '14 at 1:18
2

You can with various filters.

  1. Search for the package name or the class name you want to see example code using.

  2. On the side, click on Code and this will filter results to show you just the source code, not repositories (which is the default search result view).

  3. If the framework, package or module you're looking for shares a name with something else in another language, filter by selecting the language.

  4. If from looking at the search results you see words you don't think are indicative of the examples you want to review, add NOT word-to-exclude as part of the search string.

For example, we'll look for example code using SwingBuilder.

swingbuilder

This returns two repositories. But we want code, so after clicking on Code now we have 3214 code results.

But that mixes in Groovy and Java. Let's narrow down with Java from the Languages list on the side. 728 results now.

But some of the results have "test" in them, and we don't want that. Change the search to:

swingbuilder NOT test

Since the search filters don't carry sometimes, you may have to repeat the Code/Language filtering to get back to where you were.

This should now improve the type of results when looking for example code.

  • I actually ended up using this as my search term: swingjavabuilder NOT Groovy NOT jacek extension:Java which was very successful. 'NOT Groovy' made the biggest difference, as I think Groovy code in a .java file is quite common. – Pureferret Jan 30 '14 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.