-
Notifications
You must be signed in to change notification settings - Fork 312
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
Reload project view, and make sure that BazelImportSettings respect p… #7088
Reload project view, and make sure that BazelImportSettings respect p… #7088
Conversation
* so we cannot reload project view from for every of such call. | ||
* This is why we have this special case to make sure that Sync respects project view selection if there is any. | ||
*/ | ||
public static ProjectType getProjectTypeBeforeSync(@Nonnull Project project) { |
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've been also looking for a way to jump between qs/as on the fly, thanks for submitting this PR! Can we add some javadoc here to reflect somthing like returns the project type with project view file lookup
? and maybe make the name more matching the action it does rather than a point it code where it should be called?
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.
There are 15 places where Blaze.getProjectType*(project) == ProjectType.QUERY_SYNC
check is performed. So I wanted to have a special case for sync calls only. This is why name reflects this.
I don't really know how frequent the rest of places are hitting this method and saw it called from action apperance update, which cannot afford to reload file for sure.
So instead of having "get type with refresh" I'd rather keep "get type for sync and make sure the proper sync mode is used". Also we are updating BazelImportSettings
here and it is ok to update those on sync but for the rest of ops I'd like to avoid this.
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 can rename it to getSelectedProjectTypeBeforeSync
or so. The fact that BazelImportSetings
are updated is important, yet subtle here. Before, this change it was set once during project creation, and not touched afterwards, for whatever reason.
Overall, Blaze.getProjectType*(project) == ProjectType.QUERY_SYNC
is someway out of control... It is peppered over the code quite randomly, and I'm a little bit worried about it causing trouble in the future even for cases beyond sync.
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.
getRefreshedProjectType
or getNotCachedProjectType
is another option... But then it will be a dilemma where to call those :)
@@ -61,6 +54,27 @@ public BlazeProjectData loadProject(BlazeImportSettings importSettings) { | |||
|
|||
@Override | |||
public void saveProject(BlazeImportSettings importSettings, BlazeProjectData projectData) { | |||
if (projectType != Blaze.getProjectType(project)) { | |||
initBlazeProjectDataDelegate(project); |
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.
Probably we need to call save
here for the old model... But this is a thing only for Aspect one.
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.
With 50% of non-test impls not using saveProject
this interface definitely needs some cleanup...
// TODO(mathewi) Tidy up the interface to remove this unnecessary stuff.
b49a5e4
to
5bbf859
Compare
@@ -48,7 +48,7 @@ protected void runSync(Project project, AnActionEvent e) { | |||
} | |||
|
|||
public static void doIncrementalSync(Class<?> klass, Project project, @Nullable AnActionEvent e) { | |||
if (Blaze.getProjectType(project) == ProjectType.QUERY_SYNC) { | |||
if (Blaze.getProjectTypeBeforeSync(project) == ProjectType.QUERY_SYNC) { |
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 when I switch from legacy sync to aspect sync, QS is able to detect it's the first sync and falls to non-incremental sync. It happens here
intellij/base/src/com/google/idea/blaze/base/sync/actions/IncrementalSyncProjectAction.java
Lines 54 to 57 in 5ad3c3d
if (!qsm.isProjectLoaded()) { | |
qsm.onStartup(scope); | |
} else { | |
qsm.deltaSync(scope, TaskOrigin.USER_ACTION); |
On the other hand when I switch back from QS to AS, it results in Incremental Sync which might cause some unexpected issues (For example leftoveers after QS in project model)
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.
private static boolean allTargetsBuild(SyncMode mode) {
return mode == SyncMode.FULL || mode == SyncMode.INCREMENTAL;
}
With
} else {
BlazeSyncManager.getInstance(project)
.incrementalProjectSync(/* reason= */ "IncrementalSyncProjectAction");
}
public void incrementalProjectSync(String reason) {
BlazeSyncParams syncParams =
BlazeSyncParams.builder()
.setTitle("Sync")
.setSyncMode(SyncMode.INCREMENTAL)
.setSyncOrigin(reason)
.setAddProjectViewTargets(true)
.setAddWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet())
.build();
requestProjectSync(syncParams);
}
And "Full" is:
public void fullProjectSync(String reason) {
BlazeSyncParams syncParams =
BlazeSyncParams.builder()
.setTitle("Full Sync")
.setSyncMode(SyncMode.FULL)
.setSyncOrigin(reason)
.setAddProjectViewTargets(true)
.setAddWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet())
.build();
requestProjectSync(syncParams);
}
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.
TBH I've been using "INCREMENTAL" all this time and there is nothing really incremental about it :)
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.
well, this means INCREMENTAL
was pretty good, theoretically it should always work
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.
but I would fall back to FULL, for sure external repo completions in starlark won't work
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.
After checking the code I'm not that sure about
QS is able to detect it's the first sync and falls to non-incremental sync
since nothing resets com.google.idea.blaze.base.qsync.QuerySyncManager#loadedProject
for QS to do FULL or onStartup
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.
well, here it ends up with calling onStartup
if (!qsm.isProjectLoaded()) {
qsm.onStartup(scope);
} else {
qsm.deltaSync(scope, TaskOrigin.USER_ACTION);
it just seems safer to me
33ebdc2
to
d4e2597
Compare
…roject view choice before performing sync calls.
d4e2597
to
b44bc0a
Compare
…roject view choice before performing sync calls.
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:
7087
Description of this change