[
https://issues.apache.org/jira/browse/GROOVY-12786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146030#comment-18146030
]
ASF GitHub Bot commented on GROOVY-12786:
-----------------------------------------
codeconsole opened a new pull request, #3311:
URL: https://github.com/apache/groovy/pull/3311
https://issues.apache.org/jira/browse/GROOVY-12786
Completing a dotted name whose receiver is not a known variable or class,
such as `foo.`, `[1..2].` or `import com.`, looks for `.groovy` sources of that
package. It did so with `Files.walk(Paths.get("."))`, matching every path below
the working directory, so each Tab froze groovysh for as long as that walk took.
`sourcesForPackage` now walks only the directory the package's complete
segments name (`demo.app.` walks `./demo/app`, `demo.ap` walks `./demo`). A
segment that is not a Java identifier (`[1..2].`) or a directory that does not
exist leaves nothing to walk. The sources found, and so the candidates offered,
are unchanged.
Started from a checkout with about 990,000 files:
| Tab after | 6.0.0 | `GROOVY_6_0_X` with this change |
|---|---|---|
| `[1..2].` | 22.8 s | 0.18 s |
| `import com.` | 24.9 s | 0.02 s |
| `foo.` | 22.6 s | 0.17 s |
| `java.util.` | 0.21 s | 0.17 s |
Groovy 6.0.0's groovysh always completes through this path; on master it is
the fallback when syntax checking is off, so please backport to `GROOVY_6_0_X`,
where the change applies cleanly.
> groovysh: Tab after an unknown dotted name walks the whole working directory
> ----------------------------------------------------------------------------
>
> Key: GROOVY-12786
> URL: https://issues.apache.org/jira/browse/GROOVY-12786
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> Tab completion of a dotted name whose receiver is not a known variable or
> class, such as {{foo.}}, {{[1..2].}} or {{import com.}}, freezes groovysh for
> as long as it takes to walk every file below the directory groovysh was
> started in. {{GroovyEngine.Helpers.sourcesForPackage}} looks for {{.groovy}}
> sources of the package with {{Files.walk(Paths.get("."))}} and matches each
> path against the package, so the whole tree is walked even when the name
> cannot be a package.
> Started from a checkout with about 990,000 files, Groovy 6.0.0 takes 22 to 25
> seconds for each such Tab; from an empty directory it takes 0.2 seconds.
> Groovy 6.0.0's groovysh always completes this way; on master the shell
> completer is the fallback when syntax checking is off.
> Only the directory named by the complete segments of the package needs
> walking: a name with a segment that is not a Java identifier, or whose
> directory does not exist, has no sources to find.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)