[seam-commits] Seam SVN: r13391 - in sandbox/encore: core/src/test/java/org/jboss/encore/grammar/java and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Jul 14 12:27:08 EDT 2010
Author: lincolnthree
Date: 2010-07-14 12:27:07 -0400 (Wed, 14 Jul 2010)
New Revision: 13391
Modified:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
Log:
Default commands may no longer be executed by plug-in-name + command-name, only by plugin-name (arguments matching the command method name are now treated as regular parameters to the default command.)
Parser can now remove java methods.
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -176,7 +176,7 @@
{
if (getMethods().contains(method))
{
- getTypeDeclaration().bodyDeclarations().remove(method);
+ getTypeDeclaration().bodyDeclarations().remove(method.getInternal());
}
return this;
}
Modified: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -107,10 +107,10 @@
public void testRemoveMethod() throws Exception
{
// TODO Removing methods needs to work
- // List<Method> methods = javaClass.getMethods();
- // javaClass.removeMethod(methods.get(0)).applyChanges();
- // methods = javaClass.getMethods();
- // assertEquals(1, methods.size());
+ List<Method> methods = javaClass.getMethods();
+ javaClass.removeMethod(methods.get(0)).applyChanges();
+ methods = javaClass.getMethods();
+ assertEquals(1, methods.size());
}
@Test
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -136,8 +136,10 @@
{
String currentPrompt = reader.getPrompt();
reader.setPrompt(" ");
+ reader.removeCompleter(completer);
String line = reader.readLine();
reader.setPrompt(currentPrompt);
+ reader.addCompleter(completer);
return line;
}
catch (IOException e)
@@ -153,4 +155,9 @@
{
System.out.println(line);
}
+
+ public String prompt()
+ {
+ return prompt("");
+ }
}
\ No newline at end of file
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -95,14 +95,18 @@
commandMeta.setDefault(true);
}
- if (command.value().length == 0)
+ // Default commands are invoked via the name of the plug-in, not by plug-in + command
+ if (!commandMeta.isDefault())
{
- commandMeta.setNames(m.getName().toLowerCase());
+ if (command.value().length == 0)
+ {
+ commandMeta.setNames(m.getName().toLowerCase());
+ }
+ else
+ {
+ commandMeta.setNames(command.value());
+ }
}
- else
- {
- commandMeta.setNames(command.value());
- }
Class<?>[] parameterTypes = m.getParameterTypes();
Annotation[][] parameterAnnotations = m.getParameterAnnotations();
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -44,6 +44,11 @@
@Command(help = "This is a demo command")
public void run(@Option(help = "The text to be echoed") final String text)
{
- shell.write("Echo plugin says: \"" + text + "\"");
+ String input = text;
+ if (input == null)
+ {
+ input = shell.prompt();
+ }
+ shell.write("Echo plugin says: \"" + input + "\"");
}
}
More information about the seam-commits
mailing list