-
Notifications
You must be signed in to change notification settings - Fork 322
Allow to have non-existent import entries in projectview
that pointing to …
#5689
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
Allow to have non-existent import entries in projectview
that pointing to …
#5689
Conversation
…files that are optional and can be missing for some of the users.
@@ -303,11 +306,26 @@ public void testCanParseWithMissingCarriageReturnAtEndOfSection() { | |||
|
|||
@Test | |||
public void testImportMissingFileResultsInIssue() { | |||
Registry.get("bazel.projectview.optional.imports").setValue(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unable to make it work with Registry.is('bla', false)
for tests.
@@ -55,6 +55,10 @@ public void assertHasErrors() { | |||
assertThat(issues.stream().anyMatch(i -> i.getCategory() == Category.ERROR)).isTrue(); | |||
} | |||
|
|||
public void assertHasNoErrors() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in some cases there are issues but those are not errors.
base/src/com/google/idea/blaze/base/projectview/section/sections/ImportSection.java
Outdated
Show resolved
Hide resolved
codewise lgtm, haven't checked how it works IRL. @tpasternak could you please check this? related though: I'd be happy to see warnings (primarily highlighting) in editor on unresolved imports when feature is enabled, though I believe it falls outside of the scope of proposed change. |
sigh... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a discussion about this feature and the common point was that primarily in all programming languages imports require imported entity to exist. Though for example python allows to handle import errors, so can we keep import
statement as is and just introduce try_import
which will allow imported entity to be absent?
I don't think that |
@ujohnny please note that this is protected by registry value and not default behavior. Our use case is following:
In our case we want to have freedom to remove any imported file without much deprecation process. If we go via Could you please consider approving this PR and if someone needs |
With your suggestion we need to ask EVERY engineer to replace |
@dkashyn-sfdc you could leave implicit optional import support under the flag, but please then make |
@ujohnny could you please check now? I'll think of other tests if the approach is correct. |
@@ -52,10 +52,12 @@ public <T> List<T> listItems(SectionKey<T, ListSection<T>> key) { | |||
} | |||
|
|||
/** Returns all values from all scalar sections in the project views, in order */ | |||
public <T> List<T> listScalarItems(SectionKey<T, ScalarSection<T>> key) { | |||
public <T> List<T> listScalarItems(SectionKey<T, ScalarSection<T>>... keys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure whether this is a good idea so can redo if someone have strong opinions against this way
Added as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @tpasternak would you like to check this?
@@ -599,6 +600,9 @@ public void updateBuilder(BlazeNewProjectBuilder builder) { | |||
.add( | |||
ScalarSection.builder(ImportSection.KEY) | |||
.set(selectProjectViewOption.getSharedProjectView())) | |||
.add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed? It results in having both import and try_import sections in the generated local projectview file even with the flag disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ok to use both import
and try_import
. It might be not ok to have some duplication or excessive defaults...
Could you please share more context for your inquiry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know why it is needed to add a try_import
in this function? If I understand correctly, this function creates a project view that imports the shared project view file selected in the import process. So import
section should be enough and there is no need to try_import
the same project view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mai93 there might be "mandatory" and "optional" imports in any project view. One example of optional would be
try_import:
~/.some.local.projectview
(let's assume ~
is resolved to user home dir ;) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I'm still not sure what the effect of having something like:
import hello/hello.bazelproject
try_import hello/hello.bazelproject
will this provide a different result from only
import hello/hello.bazelproject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is rather for
import hello/fail.if.not.present.bazelproject
try_import hello/ok.if.not.present.bazelproject
That can result in:
- both imported
- only
hello/fail.if.not.present.bazelproject
imported and accepting the fact that thattry_import hello/ok.if.not.present.bazelproject
is not there - failing if
hello/fail.if.not.present.bazelproject
is missing
Optional imports will allow engineers to have pre-defined custom import files both present or missing.
Now it is possible for some of the users to benefit from custom contents while other users not affected even if they have no local customizations. For both groups of users the same .bazelproject
can be stored in VCS now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so there is no additional value for having:
import hello/hello.bazelproject
try_import hello/hello.bazelproject
right? If so, then the change in this line can be reverted because it adds try_import
section for the same project view file: selectProjectViewOption.getSharedProjectView()
that already was added with import
in line 600.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…files that are optional and can be missing for some of the users.
Checklist
Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.
Discussion thread for this change
Issue number:
5688
Description of this change