Skip to content

Commit

Permalink
chore: drop 222: Inline attach sources provider (#6731)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpasternak authored Sep 5, 2024
1 parent 9b26850 commit 117df86
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.settings.BlazeImportSettings.ProjectType;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.sdkcompat.java.AttachSourcesProviderAdapter;
import com.intellij.codeInsight.AttachSourcesProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.libraries.Library;
Expand All @@ -35,10 +35,9 @@

/** */
public class AddLibraryTargetDirectoryToProjectViewAttachSourcesProvider
extends AttachSourcesProviderAdapter {
implements AttachSourcesProvider {

@NotNull
@Override
public Collection<AttachSourcesAction> getAdapterActions(
List<? extends LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
Project project = psiFile.getProject();
Expand Down Expand Up @@ -69,7 +68,7 @@ public Collection<AttachSourcesAction> getAdapterActions(
}

return ImmutableList.of(
new AttachSourcesActionAdapter() {
new BlazeAttachSourceProvider.AttachSourcesActionAdapter() {
@Override
public String getName() {
return "Add Source Directories To Project View";
Expand All @@ -88,4 +87,11 @@ public ActionCallback adapterPerform(List<? extends LibraryOrderEntry> orderEntr
}
});
}

@NotNull
@Override
public Collection<AttachSourcesAction> getActions(
List<? extends LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
return getAdapterActions(orderEntries, psiFile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.google.idea.blaze.java.sync.model.BlazeJarLibrary;
import com.google.idea.common.experiments.BoolExperiment;
import com.google.idea.common.util.Transactions;
import com.google.idea.sdkcompat.java.AttachSourcesProviderAdapter;
import com.intellij.codeInsight.AttachSourcesProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.TransactionGuard;
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
Expand All @@ -39,6 +39,8 @@
import com.intellij.openapi.util.ActionCallback;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.List;
import javax.annotation.Nullable;
Expand All @@ -49,12 +51,11 @@
*
* <p>Optionally also attaches sources automatically, on demand.
*/
public class BlazeAttachSourceProvider extends AttachSourcesProviderAdapter {
public class BlazeAttachSourceProvider implements AttachSourcesProvider {

private static final BoolExperiment attachAutomatically =
new BoolExperiment("blaze.attach.source.jars.automatically.3", true);

@Override
public Collection<AttachSourcesAction> getAdapterActions(
List<? extends LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
Project project = psiFile.getProject();
Expand Down Expand Up @@ -178,4 +179,20 @@ private static void attachSources(
modelsProvider.commit();
});
}

@NotNull
@Override
public Collection<AttachSourcesAction> getActions(
List<? extends LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
return getAdapterActions(orderEntries, psiFile);
}

public static abstract class AttachSourcesActionAdapter implements AttachSourcesAction {
public abstract ActionCallback adapterPerform(List<? extends LibraryOrderEntry> orderEntriesContainingFile);


public ActionCallback perform(List<? extends LibraryOrderEntry> orderEntriesContainingFile) {
return adapterPerform(orderEntriesContainingFile);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 117df86

Please sign in to comment.