[
https://issues.apache.org/jira/browse/GROOVY-12448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun updated GROOVY-12448:
--------------------------------
Description:
h2. Context
GROOVY-12411 added {{groovy-lsp}} and an in-process
{{{}GroovyLanguageEngine{}}}. That work left Groovy Console and groovysh
unconnected. This change attaches those two hosts to the same engine so an
unsaved buffer can be queried for diagnostics, completion, hover, and
signatures without generating class files.
Scripts still run through {{GroovyShell}} in the console and {{GroovyEngine}}
in groovysh.
h2. User-visible behavior
* *Groovy Console.* The editor compiles the unsaved buffer in the background
and highlights compiler diagnostics. {{Ctrl+Space}} offers compiler-backed
completions. Adding a jar or directory to the classpath is picked up on the
next compile.
* *groovysh.* Tab completion and tail-tip descriptions consult the compiler
for the current buffer (imports, types, methods, and binding variables). Syntax
tail-tips report diagnostics and do not evaluate the line. {{/grab}} remains
the way to add Maven artifacts; the next completion or tail-tip notices the
loader change.
h2. Design
* {{groovy-console}} and {{groovy-groovysh}} take an {{implementation}}
dependency on {{{}groovy-lsp{}}}.
* Adapters stay in the host trees: {{ConsoleLanguageHost}} (buffer URI
{{{}groovy-buffer:console{}}}) and {{GroovyshLanguageSession}} (buffer URI
{{{}groovy-buffer:repl{}}}). The engine does not assign those names. Both
adapters are {{@Internal}} and are not an embedding API.
* Queries return JDK records. Host source does not import LSP4J. Feature
services inside {{groovy-lsp}} still use LSP4J types, so LSP4J remains a
runtime dependency of these hosts.
* Positions are 0-based UTF-16.
* The compile fingerprint includes {{URLClassLoader}} URLs, so an in-place
{{addURL}} (console classpath menu, groovysh {{{}/grab{}}}) is visible on the
next compile.
* groovysh composes {{{}GroovyEngine.getBuffer(){}}}, declaration-only binding
types for names the buffer does not already introduce, and the current line.
Those names come from the compiled AST
({{{}GroovyLanguageEngine.declaredNames{}}}).
* groovysh {{SYNTAX}} tail-tips return compiler diagnostics and do not fall
through to Inspector {{{}checkSyntax{}}}, which evaluates. {{METHOD}}
signatures use the full {{CmdLine.line}} so an unclosed opening parenthesis is
visible. Inspector is used only when the compiler has no signatures.
h2. Out of scope
* Driving AstBrowser from an LSP snapshot.
* A public embedding API for the adapters.
* Splitting a protocol-free engine module out of {{{}groovy-lsp{}}}.
was:
h2. Context
GROOVY-12411 added {{groovy-lsp}} and an in-process {{GroovyLanguageEngine}}.
That work left Groovy Console and groovysh unconnected. This change attaches
those two hosts to the same engine so an unsaved buffer can be queried for
diagnostics, completion, hover, and signatures without generating class files.
Scripts still run through {{GroovyShell}} in the console and {{GroovyEngine}}
in groovysh.
h2. User-visible behavior
* *Groovy Console.* The editor compiles the unsaved buffer in the background
and highlights compiler diagnostics. {{Ctrl+Space}} offers compiler-backed
completions. Adding a jar or directory to the classpath is picked up on the
next compile.
* *groovysh.* Tab completion and tail-tip descriptions consult the compiler for
the current buffer (imports, types, methods, and binding variables). Syntax
tail-tips report diagnostics and do not evaluate the line. {{/grab}} remains
the way to add Maven artifacts; the next completion or tail-tip notices the
loader change.
h2. Design
* {{groovy-console}} and {{groovy-groovysh}} take an {{implementation}}
dependency on {{groovy-lsp}}.
* Adapters stay in the host trees: {{ConsoleLanguageHost}} (buffer URI
{{groovy-buffer:console}}) and {{GroovyshLanguageSession}} (buffer URI
{{groovy-buffer:repl}}). The engine does not assign those names. Both adapters
are {{{}@Internal{}}} and are not an embedding API.
* Queries return JDK records. Host source does not import LSP4J. Feature
services inside {{groovy-lsp}} still use LSP4J types, so LSP4J remains a
runtime dependency of these hosts.
* Positions are 0-based UTF-16.
* The compile fingerprint includes {{URLClassLoader}} URLs, so an in-place
{{addURL}} (console classpath menu, groovysh {{/grab}}) is visible on the next
compile.
* groovysh composes {{GroovyEngine.getBuffer()}}, declaration-only binding
types for names the buffer does not already introduce, and the current line.
Those names come from the compiled AST ({{GroovyLanguageEngine.declaredNames}}).
* groovysh {{SYNTAX}} tail-tips return compiler diagnostics and do not fall
through to Inspector {{checkSyntax}}, which evaluates. {{METHOD}} signatures
use the full {{CmdLine.line}} so an unclosed opening parenthesis is visible.
Inspector is used only when the compiler has no signatures.
h2. Out of scope
* Replacing SmartDocumentFilter or the nanorc highlighter with semantic tokens.
* Driving AstBrowser from an LSP snapshot.
* A public embedding API for the adapters.
* Splitting a protocol-free engine module out of {{groovy-lsp}}.
> Wire Groovy Console and groovysh to the in-process language engine
> ------------------------------------------------------------------
>
> Key: GROOVY-12448
> URL: https://issues.apache.org/jira/browse/GROOVY-12448
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Priority: Major
>
> h2. Context
> GROOVY-12411 added {{groovy-lsp}} and an in-process
> {{{}GroovyLanguageEngine{}}}. That work left Groovy Console and groovysh
> unconnected. This change attaches those two hosts to the same engine so an
> unsaved buffer can be queried for diagnostics, completion, hover, and
> signatures without generating class files.
> Scripts still run through {{GroovyShell}} in the console and {{GroovyEngine}}
> in groovysh.
> h2. User-visible behavior
> * *Groovy Console.* The editor compiles the unsaved buffer in the background
> and highlights compiler diagnostics. {{Ctrl+Space}} offers compiler-backed
> completions. Adding a jar or directory to the classpath is picked up on the
> next compile.
> * *groovysh.* Tab completion and tail-tip descriptions consult the compiler
> for the current buffer (imports, types, methods, and binding variables).
> Syntax tail-tips report diagnostics and do not evaluate the line. {{/grab}}
> remains the way to add Maven artifacts; the next completion or tail-tip
> notices the loader change.
> h2. Design
> * {{groovy-console}} and {{groovy-groovysh}} take an {{implementation}}
> dependency on {{{}groovy-lsp{}}}.
> * Adapters stay in the host trees: {{ConsoleLanguageHost}} (buffer URI
> {{{}groovy-buffer:console{}}}) and {{GroovyshLanguageSession}} (buffer URI
> {{{}groovy-buffer:repl{}}}). The engine does not assign those names. Both
> adapters are {{@Internal}} and are not an embedding API.
> * Queries return JDK records. Host source does not import LSP4J. Feature
> services inside {{groovy-lsp}} still use LSP4J types, so LSP4J remains a
> runtime dependency of these hosts.
> * Positions are 0-based UTF-16.
> * The compile fingerprint includes {{URLClassLoader}} URLs, so an in-place
> {{addURL}} (console classpath menu, groovysh {{{}/grab{}}}) is visible on the
> next compile.
> * groovysh composes {{{}GroovyEngine.getBuffer(){}}}, declaration-only
> binding types for names the buffer does not already introduce, and the
> current line. Those names come from the compiled AST
> ({{{}GroovyLanguageEngine.declaredNames{}}}).
> * groovysh {{SYNTAX}} tail-tips return compiler diagnostics and do not fall
> through to Inspector {{{}checkSyntax{}}}, which evaluates. {{METHOD}}
> signatures use the full {{CmdLine.line}} so an unclosed opening parenthesis
> is visible. Inspector is used only when the compiler has no signatures.
> h2. Out of scope
> * Driving AstBrowser from an LSP snapshot.
> * A public embedding API for the adapters.
> * Splitting a protocol-free engine module out of {{{}groovy-lsp{}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)