Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Members with $L (and others) support by addStaticImport() #443

Open
wants to merge 1 commit into
base: master
from

Conversation

@sormuras
Copy link
Contributor

commented Mar 19, 2016

Motivation

Current JavaFile//addStaticImport implementation "doesn't support members with $L". See 4dd5349

Features

  • $T.$L and many (all ?) other cases are now supported
  • It does not fail on intentional white spaces either, like "$T . $N = PI"
  • Auto-skips unused import static requests

Implementation outline

  • Hooked into lookup(ClassName) and emitAndIndent(String) now.
  • When a potential hit for a static import is detected, lookup returns an empty string and the ClassName instance is remembered as deferred.
  • While there's a deferred ClassName, all strings (coming from any accelerator like $L, $N, ...) emitted via emitAndIndent(String) are gathered and analyzed for a wildcard or perfect match.
  • Depending on the match result: if hit, emit only the member part or emit the deferred class name.
@sormuras sormuras referenced this pull request Mar 19, 2016
@sormuras sormuras referenced this pull request Aug 18, 2016
@jollytoad

This comment has been minimized.

Copy link

commented Mar 15, 2018

Hi, I've just hit the problem of ("$T.$N", SomeType.class, "methodName") not being supported by addStaticImport too. I've seen there has been many discussion around this, and a possible MemberRef. I'm just wondering what the current state is for this issue? Is it being worked on or has it stalled?

@sormuras

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2018

IIRC, last time I spoke with @swankjesse about it, he was almost okay with adding $R. Almost. :)

Regarding this PR: it only needs a little lift, and all is green again. Without introducing $R. But the integration into the emit-phase is not ... trivial. I guess, this is why the PR was never merged.

@sormuras sormuras force-pushed the sormuras:static_import_refactored branch from e516b00 to e882355 Mar 15, 2018

@sormuras

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2018

Rebased and conflicts resolved.

@sormuras

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2018

...and works like a charm with the corrected TYPE_USE annotations as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.