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

turn off "Insert imports for inner classes" #2736

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Feb 29, 2024

Before this PR

Our internal ski product database tooling does a lot of codegen and creates many inner classes called Key. Today, I find that I often want to reference a few of these classes (e.g. MyTable.Key key = ... and OtherTable.Key key2 = ...) but IntelliJ immediately simplifies the first import into Key key = ... which then trips over the BadImport static analysis which complaints about commonly-used names being ambiguous.

I have started just unticking this box:

image

After this PR

==COMMIT_MSG==
turn off "Insert imports for inner classes"
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Feb 29, 2024

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

turn off "Insert imports for inner classes"

Check the box to generate changelog(s)

  • Generate changelog entry

@carterkozak
Copy link
Contributor

fwiw I strongly prefer not to import inner classes as well, since the outer class name should provide a fair bit of context (more so than a package provides for a top-level class name). Other folks may have different opinions though, so I'll leave this up for another day or so in case others have feedback.

@LouisCaubet
Copy link

LouisCaubet commented Feb 29, 2024

Main reason we want this is because some other part of the tooling makes compilation fail when inner classes are imported that way:

Screenshot 2024-02-29 at 17 32 03

@pkoenig10
Copy link
Member

pkoenig10 commented Mar 20, 2024

My default is also to prefer avoiding inner imports, but I think this is hugely context dependent.

For example, AtlasDB's generated table classes contains all row, column, and column value for that table and the table name is repeated in each of the types. For example, here's a real set of imports from an internal product - and this is not uncommon:

import com.palantir.mp.atlas.generated.ClientsTable;
import com.palantir.mp.atlas.generated.ClientsTable.AllowedClientsIdxTable;
import com.palantir.mp.atlas.generated.ClientsTable.AllowedClientsIdxTable.AllowedClientsIdxColumn;
import com.palantir.mp.atlas.generated.ClientsTable.AllowedClientsIdxTable.AllowedClientsIdxRow;
import com.palantir.mp.atlas.generated.ClientsTable.ClientsNamedColumn;
import com.palantir.mp.atlas.generated.ClientsTable.ClientsRow;
import com.palantir.mp.atlas.generated.ClientsTable.ClientsRowResult;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToOrganizationClientIdIdxTable;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToOrganizationClientIdIdxTable.OrganizationIdToOrganizationClientIdIdxColumn;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToOrganizationClientIdIdxTable.OrganizationIdToOrganizationClientIdIdxRow;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToPersonalClientIdIdxTable;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToPersonalClientIdIdxTable.OrganizationIdToPersonalClientIdIdxColumn;
import com.palantir.mp.atlas.generated.ClientsTable.OrganizationIdToPersonalClientIdIdxTable.OrganizationIdToPersonalClientIdIdxRow;
import com.palantir.mp.atlas.generated.ClientsTable.OwnerUserIdToPersonalClientIdIdxTable;
import com.palantir.mp.atlas.generated.ClientsTable.OwnerUserIdToPersonalClientIdIdxTable.OwnerUserIdToPersonalClientIdIdxRow;

I'd much prefer to leave this option to users. IntelliJ makes it easy to configure this globally, so you only have to disable inner import or define a set of exclusions once. If our tooling overrides the global setting, then I have to manually re-enable this for ever repo I work on. In general, I'd much prefer we give people the flexibility to configure their development environments how they would like rather than imposing a particular workflow.

@iamdanfox
Copy link
Contributor Author

ok - shall I just delete the xml line entirely then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants