This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 8a7e716b2518268db2767f2b62181a7f00f9ac9e
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Mar 7 21:56:50 2020 +0800

    Minor refactoring: extract class `CstInspector`
---
 .../main/groovy/groovy/console/ui/Console.groovy   | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git 
a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy 
b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
index 60a91aa..6117100 100644
--- 
a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
+++ 
b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
@@ -1047,16 +1047,27 @@ class Console implements CaretListener, 
HyperlinkListener, ComponentListener, Fo
         new AstBrowser(inputArea, rootElement, shell.getClassLoader(), 
config).run({ inputArea.getText() })
     }
 
+    @CompileStatic
+    private static class CstInspector extends TestRig {
+        CstInspector() throws Exception {
+            super(new String[] { 'Groovy', 'compilationUnit', '-gui' })
+        }
+
+        void inspectParseTree(String text) {
+            CharStream charStream = CharStreams.fromReader(new 
StringReader(text))
+            GroovyLangLexer lexer = new GroovyLangLexer(charStream)
+            CommonTokenStream tokens = new CommonTokenStream(lexer)
+            GroovyLangParser parser = new GroovyLangParser(tokens)
+            process(lexer, GroovyLangParser.class, parser, charStream)
+        }
+    }
+
+    @CompileStatic
     void inspectCst(EventObject evt = null) {
         String text = this.inputEditor.textEditor.text
 
-        CharStream charStream = CharStreams.fromReader(new StringReader(text))
-        GroovyLangLexer lexer = new GroovyLangLexer(charStream)
-        CommonTokenStream tokens = new CommonTokenStream(lexer)
-        GroovyLangParser parser = new GroovyLangParser(tokens)
-
-        def tr = new TestRig(new String[] { 'Groovy', 'compilationUnit', 
'-gui' })
-        tr.process(lexer, GroovyLangParser.class, parser, charStream)
+        def gtr = new CstInspector()
+        gtr.inspectParseTree(text)
     }
 
     void inspectTokens(EventObject evt = null) {

Reply via email to