-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REPL console: added Printer interface and a groovy command inspect
- Loading branch information
Showing
10 changed files
with
430 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251 changes: 152 additions & 99 deletions
251
builtins/src/main/java/org/jline/builtins/ConsoleEngineImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
groovy/src/main/groovy/org/jline/groovy/ObjectInspector.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2002-2020, the original author or authors. | ||
* | ||
* This software is distributable under the BSD license. See the terms of the | ||
* BSD license in the documentation provided with this software. | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
package org.jline.groovy | ||
|
||
import java.lang.reflect.* | ||
|
||
public class ObjectInspector { | ||
public static final List<String> METHOD_COLUMNS = ['language','modifiers','this','return','name','parameters','exception','8'] | ||
def obj | ||
def inspector | ||
|
||
public ObjectInspector(def obj) { | ||
this.obj = obj | ||
this.inspector = new groovy.inspect.Inspector(obj) | ||
} | ||
|
||
List<Map<String, String>> methods() { | ||
def out = [] | ||
inspector.methods.each { | ||
def mdef = [:] | ||
for (int i = 0; i < it.size(); i++) { | ||
mdef.put(METHOD_COLUMNS.get(i), it.getAt(i)) | ||
} | ||
out.add(mdef) | ||
} | ||
out | ||
} | ||
|
||
List<Map<String, String>> metaMethods() { | ||
def out = [] | ||
inspector.metaMethods.each { | ||
def mdef = [:] | ||
for (int i = 0; i < it.size(); i++) { | ||
mdef.put(METHOD_COLUMNS.get(i),it.getAt(i)) | ||
} | ||
out.add(mdef) | ||
} | ||
out | ||
} | ||
|
||
def properties() { | ||
def out = [:] | ||
def props=['propertyInfo', 'publicFields', 'classProps'] | ||
props.each { | ||
def val = inspector.properties.get(it) | ||
out.put(it, val) | ||
} | ||
out | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.