use of com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method initTest.
@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(Container applicationServices, Container projectServices) {
applicationServices.register(ExperimentService.class, new MockExperimentService());
BlazeExecutor blazeExecutor = new MockBlazeExecutor();
applicationServices.register(BlazeExecutor.class, blazeExecutor);
projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
// will silently fall back to FilePathJavaPackageReader
applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {
@Nullable
@Override
public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
return null;
}
});
applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
applicationServices.register(PrefetchService.class, new MockPrefetchService());
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
augmenters = registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
}
use of com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder in project intellij by bazelbuild.
the class AbstractPyImportResolverStrategy method buildSourcesIndex.
@SuppressWarnings("unused")
private PySourcesIndex buildSourcesIndex(Project project, BlazeProjectData projectData) {
ImmutableSetMultimap.Builder<String, QualifiedName> shortNames = ImmutableSetMultimap.builder();
Map<QualifiedName, PsiElementProvider> map = new HashMap<>();
ArtifactLocationDecoder decoder = projectData.artifactLocationDecoder;
for (TargetIdeInfo target : projectData.targetMap.targets()) {
for (ArtifactLocation source : getPySources(target)) {
QualifiedName name = toImportString(source);
if (name == null || name.getLastComponent() == null) {
continue;
}
shortNames.put(name.getLastComponent(), name);
PsiElementProvider psiProvider = psiProviderFromArtifact(decoder, source);
map.put(name, psiProvider);
if (includeParentDirectory(source)) {
map.put(name.removeTail(1), PsiElementProvider.getParent(psiProvider));
}
}
}
return new PySourcesIndex(shortNames.build(), ImmutableMap.copyOf(map));
}
use of com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder in project intellij by bazelbuild.
the class TestTargetSourcesHeuristic method matchesSource.
@Override
public boolean matchesSource(Project project, TargetInfo target, @Nullable PsiFile sourcePsiFile, File sourceFile, @Nullable TestSize testSize) {
Optional<ImmutableList<ArtifactLocation>> sources = target.getSources();
if (!sources.isPresent()) {
return false;
}
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return false;
}
ArtifactLocationDecoder decoder = projectData.artifactLocationDecoder;
for (ArtifactLocation src : sources.get()) {
if (decoder.decode(src).equals(sourceFile)) {
return true;
}
}
return false;
}
use of com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder in project intellij by bazelbuild.
the class MockBlazeProjectDataBuilder method build.
public BlazeProjectData build() {
TargetMap targetMap = this.targetMap != null ? this.targetMap : new TargetMap(ImmutableMap.of());
BlazeInfo blazeInfo = this.blazeInfo;
if (blazeInfo == null) {
String outputBase = this.outputBase != null ? this.outputBase : "/usr/workspace/1234";
blazeInfo = BlazeInfo.createMockBlazeInfo(outputBase, outputBase + "/execroot", outputBase + "/execroot/bin", outputBase + "/execroot/gen");
}
BlazeVersionData blazeVersionData = this.blazeVersionData != null ? this.blazeVersionData : BlazeVersionData.builder().build();
WorkspacePathResolver workspacePathResolver = this.workspacePathResolver != null ? this.workspacePathResolver : new WorkspacePathResolverImpl(workspaceRoot);
ArtifactLocationDecoder artifactLocationDecoder = this.artifactLocationDecoder != null ? this.artifactLocationDecoder : new ArtifactLocationDecoderImpl(blazeInfo, workspacePathResolver);
WorkspaceLanguageSettings workspaceLanguageSettings = this.workspaceLanguageSettings != null ? this.workspaceLanguageSettings : new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of());
SyncState syncState = this.syncState != null ? this.syncState : new SyncState(ImmutableMap.of());
ImmutableMultimap<TargetKey, TargetKey> reverseDependencies = this.reverseDependencies != null ? this.reverseDependencies : ImmutableMultimap.of();
return new BlazeProjectData(syncTime, targetMap, blazeInfo, blazeVersionData, workspacePathResolver, artifactLocationDecoder, workspaceLanguageSettings, syncState, reverseDependencies);
}
use of com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder in project intellij by bazelbuild.
the class JdepsFileReader method loadJdepsFiles.
/**
* Loads any updated jdeps files since the last invocation of this method.
*/
@Nullable
public JdepsMap loadJdepsFiles(Project project, BlazeContext parentContext, ArtifactLocationDecoder artifactLocationDecoder, Iterable<TargetIdeInfo> targetsToLoad, SyncState.Builder syncStateBuilder, @Nullable SyncState previousSyncState) {
JdepsState oldState = previousSyncState != null ? previousSyncState.get(JdepsState.class) : null;
JdepsState jdepsState = Scope.push(parentContext, (context) -> {
context.push(new TimingScope("LoadJdepsFiles", EventType.Other));
return doLoadJdepsFiles(project, context, artifactLocationDecoder, oldState, targetsToLoad);
});
if (jdepsState == null) {
return null;
}
syncStateBuilder.put(JdepsState.class, jdepsState);
return targetKey -> jdepsState.targetToJdeps.get(targetKey);
}
Aggregations