# Is it possible to find methods in source code using \inputminted?

My document MWE:

\documentclass[12pt,a4paper]{mwrep}
\usepackage{minted}
\begin{document}
\inputminted[gobble=4,firstnumber=3,firstline=3,lastline=9,linenos,tabsize=4]{java}{Foo.java}
\end{document}


Content of Foo.java:

public class Foo
{
public static void main(String[] args)
{
for(int i=0; i<10; i++)
{
System.out.println(i);
}
}
}


Presented TeX document will show and format method main. When I change the code of Foo class (e.g. add a new method above main or expand it), I would need to manually change the range of lines to show. Can it somehow be done automatically? I think of comments as a markers in the java code. Something like in one of the examples below:

public class Foo
{
//start-main
public static void main(String[] args)
{
for(int i=0; i<10; i++)
{
System.out.println(i);
}
}
//end-main
}


or

public class Foo
{
public static void main(String[] args) //start-main
{
for(int i=0; i<10; i++)
{
System.out.println(i);
}
} //end-main
}


Is it possible to pass this to LaTeX (or Pygments in this case)? I would like to be able to ignore those markers when presenting a larger portion of code (e.g. whole Foo.java file) but this is not as important as the main question. Maybe there is another way without any markers? For example telling Pygments to print main method from Foo class.
Of course I don't want to be limited to methods only. I want to be able to mark any part of the code this way.

-
I will use listings package instead. –  Who is crazy first Nov 24 '11 at 5:08
@CounterTerrorist, does listings have this feature? I prefer minted beceuse of better looking output. –  Ichibann Nov 24 '11 at 12:23
@Ichibann: I agree that the default output of minted is somewhat more polished that the default output of listings; however, listings is pretty flexible wrt adapting the typesetting. If you search for the listings tag you will find a couple of "good looking" (well, it's a matter of taste...) examples (such as tex.stackexchange.com/questions/18376/…). –  Daniel Nov 24 '11 at 20:32
The following is taken from listings manual page 51 and 52.
Yes, this is nice :). If there were something like this in minted... –  Ichibann Nov 24 '11 at 17:47