Thanks for the response Caoyuan.
Anyone else who might be writing many small standalone programs to
learn Scala, I've written the Scala program below (my first) that
allows them to be easily run in Netbeans while waiting for Caoyuan's
updated plugin. Compile it with the -Xno-varargs-conversion option
and set it as the main class in Netbeans. When run, it prompts for
the class to invoke in the "Output" area. Just type in a
package.class name.
import java.lang.reflect.Modifier
import java.lang.reflect.Method
import java.util.Scanner
object run extends Application
{
var debug = false
println("type class name to run: ")
if (!invoke(new Scanner(System.in).nextLine()))
println("main not found")
def invoke(fileName: String): Boolean =
{
var invoked = false
try
{
for ( m <- Class.forName(fileName).getDeclaredMethods)
{
if (debug)
printStuff(m)
val modString = Modifier.toString(m.getModifiers)
val parms = m.getParameterTypes
if ((parms.length == 1) &&
(m.getReturnType == classOf[Unit]) &&
( parms(0).isArray()) &&
(parms(0).getComponentType() == classOf[String])
&&
(modString.equals("public static final")) &&
m.getName().equals("main"))
{
m.invoke(null, new Array[String](0)) // dummy
parms
invoked = true
}
}
}
catch
{
case y: ClassNotFoundException => println(y)
case x: Exception => x.printStackTrace
}
invoked
}
def printStuff(m: Method) : Unit =
{
format("%s%n", m.toGenericString());
format(" Simple Name: %s%n", m.getName())
format(" Modifiers: %s%n",
Modifier.toString(m.getModifiers()));
format(" Return Type: %s%n", m.getReturnType)
format(" [ synthetic=%-5b var_args=%-5b bridge=%-5b ]%n",
m.isSynthetic(), m.isVarArgs(), m.isBridge());
}
}
On Apr 14, 10:40 pm, Caoyuan <
dcaoy...@gmail.com> wrote:
> Hi,
>
> I plan to release a new version for NetBeans 6.7 (scheduled around
> Jun). The new release is based on my own experience of using Scala for
> NetBeans and some bug reports.
>
> On Wed, Apr 15, 2009 at 10:07 AM, watchingthecrash
>