use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.
the class BlazeModuleSystem method getLibrariesForWorkspaceModule.
private static ImmutableList<ExternalAndroidLibrary> getLibrariesForWorkspaceModule(Project project, BlazeProjectData blazeProjectData) {
ArtifactLocationDecoder decoder = blazeProjectData.getArtifactLocationDecoder();
ExternalLibraryInterner externalLibraryInterner = ExternalLibraryInterner.getInstance(project);
ImmutableList.Builder<ExternalAndroidLibrary> libraries = ImmutableList.builder();
for (BlazeLibrary library : BlazeLibraryCollector.getLibraries(ProjectViewManager.getInstance(project).getProjectViewSet(), blazeProjectData)) {
if (library instanceof AarLibrary) {
ExternalAndroidLibrary externalLibrary = toExternalLibrary(project, (AarLibrary) library, decoder);
if (externalLibrary != null) {
libraries.add(externalLibraryInterner.intern(externalLibrary));
}
}
}
return libraries.build();
}
use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.
the class BlazeAndroidLibrarySource method getLibraryFilter.
@Nullable
@Override
public Predicate<BlazeLibrary> getLibraryFilter() {
BlazeAndroidSyncData syncData = blazeProjectData.getSyncState().get(BlazeAndroidSyncData.class);
if (syncData == null) {
return null;
}
Predicate<BlazeLibrary> finalPredicate = null;
if (!syncData.importResult.aarLibraries.isEmpty()) {
finalPredicate = new AarJarFilter(syncData.importResult.aarLibraries.values());
}
if (filterResourceJarsEnabled.getValue() && !syncData.importResult.resourceJars.isEmpty()) {
Predicate<BlazeLibrary> resJarFilter = new ResourceJarFilter(syncData.importResult.resourceJars);
finalPredicate = finalPredicate == null ? resJarFilter : finalPredicate.and(resJarFilter);
}
return finalPredicate;
}
use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.
the class BlazeAttachSourceProvider method attachSources.
private static void attachSources(Project project, BlazeProjectData blazeProjectData, Collection<BlazeLibrary> librariesToAttachSourceTo) {
ApplicationManager.getApplication().runWriteAction(() -> {
IdeModifiableModelsProvider modelsProvider = BaseSdkCompat.createModifiableModelsProvider(project);
for (BlazeLibrary blazeLibrary : librariesToAttachSourceTo) {
// Make sure we don't do it twice
if (AttachedSourceJarManager.getInstance(project).hasSourceJarAttached(blazeLibrary.key)) {
continue;
}
AttachedSourceJarManager.getInstance(project).setHasSourceJarAttached(blazeLibrary.key, true);
LibraryEditor.updateLibrary(project, blazeProjectData.getArtifactLocationDecoder(), modelsProvider, blazeLibrary);
}
modelsProvider.commit();
});
}
use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.
the class JavaPrefetchFileSource method addFilesToPrefetch.
@Override
public void addFilesToPrefetch(Project project, ProjectViewSet projectViewSet, ImportRoots importRoots, BlazeProjectData blazeProjectData, Set<File> files) {
BlazeJavaSyncData syncData = blazeProjectData.getSyncState().get(BlazeJavaSyncData.class);
if (syncData == null) {
return;
}
// If we have a local jar cache we don't need to prefetch anything
if (JarCache.getInstance(project).isEnabled()) {
return;
}
Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, blazeProjectData);
ArtifactLocationDecoder decoder = blazeProjectData.getArtifactLocationDecoder();
for (BlazeLibrary library : libraries) {
if (!(library instanceof BlazeJarLibrary)) {
continue;
}
files.addAll(OutputArtifactResolver.resolveAll(project, decoder, jarArtifacts((BlazeJarLibrary) library)));
}
}
use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.
the class BlazeJavaSyncPlugin method warnAboutDeployJars.
/**
* Looks at your jars for anything that seems to be a deploy jar and warns about it. This often
* turns out to be a duplicate copy of all your application's code, so you don't want it in your
* project.
*/
private static void warnAboutDeployJars(BlazeContext context, BlazeJavaSyncData syncData) {
for (BlazeLibrary library : syncData.getImportResult().libraries.values()) {
if (!(library instanceof BlazeJarLibrary)) {
continue;
}
BlazeJarLibrary jarLibrary = (BlazeJarLibrary) library;
LibraryArtifact libraryArtifact = jarLibrary.libraryArtifact;
ArtifactLocation artifactLocation = libraryArtifact.jarForIntellijLibrary();
if (artifactLocation.isExternal()) {
return;
}
if (artifactLocation.getRelativePath().endsWith("deploy.jar") || artifactLocation.getRelativePath().endsWith("deploy-ijar.jar") || artifactLocation.getRelativePath().endsWith("deploy-hjar.jar")) {
context.output(new PerformanceWarning("Performance warning: You have added a deploy jar as a library. " + "This can lead to poor indexing performance, and the debugger may " + "become confused and step into the deploy jar instead of your code. " + "Consider redoing the rule to not use deploy jars, exclude the target " + "from your .blazeproject, or exclude the library.\n" + "Library path: " + artifactLocation.getRelativePath()));
}
}
}
Aggregations