question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResolveEngine.kt is getting big

See original GitHub issue

Maybe this is only my personal feeling, but I think ResolveEngine.kt becomes too big. It has already > 500 lines, and it’s growing.

As for now this file contains an object with multiple not-so-strictly coupled methods whose only similarity is their use case (and millions of millions of various utility functions). Some of them have even non consistent api, see:

fun resolveFieldExpr(fieldExpr: RsFieldExpr): List<RsCompositeElement>
fun resolveMethodCallExpr(call: RsMethodCallExpr): RsNamedElement?
fun resolveCallExpr(path: RustPath, element: RsPath, namespace: Namespace?): List<RsCompositeElement>
fun resolveStructExprField(structExpr: RsStructExpr, fieldName: String): List<RsNamedElement>
fun resolveUseGlob(ref: RsUseGlob): List<RsCompositeElement>
fun resolveModDecl(modDecl: RsModDeclItem): RsNamedElement?
fun resolveExternCrate(crate: RsExternCrateItem): RsNamedElement?
fun resolveLabel(label: RsLabel): RsLabelDecl?
fun resolveLifetime(lifetimeRef: RsLifetime): RsLifetimeDecl?

All these methods are named with pattern resolve{PSI element name} and so one would expect them to have also some pattern API, which they do not.

Maybe we should refactor resolve engine before it becomes total nightmare?

First of all, I think, three things have to be separated:

  • resolving by name (string) - maybe this should be converted to project service? Also current API is pretty poor (or I don’t understand how to use it); how to resolve fully qualified name without knowing in which module it is?
  • resolving PSI elements per se - maybe these ones should be converted to extension methods?
  • utils

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
matkladcommented, Apr 4, 2017

I’ve revamped the resolve engine 😃

The major change is that it is now based on scope processors, instead of sequences (instead of constructing a lazy Sequence, we pass a callback). This gives much nicer stacktraces, is actually more lazy and allows to implement stateful bits like shadowing in a more natural way. Some other improvements:

  • Shadowing and multi resolve now work by design, and not by accident. No more random .firstOrNull calls.

  • Completion and resolve now fully share code (as a bonus, we’ve got better completion for self:: and super:: without a separate completion contributror, and we’ve also got completion for lifetimes).

  • Namespaces are pushed down during resolve, which allows to get rid of some hacks.

  • String based resolve now works by creating a fake PSI element and resolving it.

We still have a zillion of methods and almost identical Reference classes though 😦

0reactions
matkladcommented, Jul 11, 2017

Yeah, I’d say the current state is better than the one from the issue creation time, and looks like @vlad20012 is going to refactor things further still!

Read more comments on GitHub >

github_iconTop Results From Across the Web

StackOverflowError when loading project in IntelliJ IDEA with ...
After upgrading from 6.7.1 to 6.8 my Kotlin multiplatform project can no longer be synced in IntelliJ IDEA. The stacktrace indicates that ...
Read more >
KJS / Gradle: Errors during NPM dependencies resolution in ...
I'm pulling my hair out trying to get something working, because it's really annoying that I have to make some edit to a...
Read more >
kapt build errors after updating to Kotlin 1.3.50 - Stack Overflow
I just updated project (and AS plugin) to Kotlin 1.3.50 and am now getting build errors like following. Anybody else experiencing this?
Read more >
Visible to Public - Issue Tracker
Run with --info or --debug option to get more log output. ... at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.A
Read more >
commit - Google Git
author, Sterling Greene <big-guy@users.noreply.github.com>, Mon Jan 28 19:27:33 2019 ... diff --git a/.teamcity/Gradle_Check/configurations/CompileAll.kt ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found