use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.
the class BlazeTreeStructureProvider method createRootNode.
@Nullable
private WorkspaceRootNode createRootNode(Project project, ViewSettings settings) {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
if (importSettings != null) {
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromImportSettings(importSettings);
File fdir = workspaceRoot.directory();
VirtualFile vdir = LocalFileSystem.getInstance().findFileByIoFile(fdir);
if (vdir != null) {
final PsiManager psiManager = PsiManager.getInstance(project);
PsiDirectory directory = psiManager.findDirectory(vdir);
return new WorkspaceRootNode(project, workspaceRoot, directory, wrapViewSettings(settings));
}
}
return null;
}
use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.
the class BlazeNewProjectBuilder method commitToProject.
/**
* Commits the project data. This method mustn't fail, because the project has already been
* created.
*/
public void commitToProject(Project project) {
BlazeWizardUserSettingsStorage.getInstance().commit(userSettings);
BlazeImportSettings importSettings = new BlazeImportSettings(workspaceRoot.directory().getPath(), projectName, projectDataDirectory, projectViewFile.getPath(), buildSystem);
BlazeImportSettingsManager.getInstance(project).setImportSettings(importSettings);
PluginDependencyHelper.addDependencyOnSyncPlugin(project);
// Initial sync of the project happens in BlazeSyncStartupActivity
}
use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.
the class PrefetchServiceImpl method prefetchProjectFiles.
@Override
public ListenableFuture<?> prefetchProjectFiles(Project project, ProjectViewSet projectViewSet, @Nullable BlazeProjectData blazeProjectData) {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
if (importSettings == null) {
return Futures.immediateFuture(null);
}
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromImportSettings(importSettings);
if (!FileOperationProvider.getInstance().exists(workspaceRoot.directory())) {
// quick sanity check before trying to prefetch each individual file
return Futures.immediateFuture(null);
}
ImportRoots importRoots = ImportRoots.builder(workspaceRoot, importSettings.getBuildSystem()).add(projectViewSet).build();
Set<File> sourceDirectories = new HashSet<>();
for (WorkspacePath workspacePath : importRoots.rootDirectories()) {
sourceDirectories.add(workspaceRoot.fileForPath(workspacePath));
}
Set<File> excludeDirectories = new HashSet<>();
for (WorkspacePath workspacePath : importRoots.excludeDirectories()) {
excludeDirectories.add(workspaceRoot.fileForPath(workspacePath));
}
ListenableFuture<?> sourceFilesFuture = prefetchFiles(project, excludeDirectories, sourceDirectories, /* refetchCachedFiles */
false, /* fetchFileTypes */
true);
Set<File> externalFiles = new HashSet<>();
if (blazeProjectData != null) {
for (PrefetchFileSource fileSource : PrefetchFileSource.EP_NAME.getExtensions()) {
fileSource.addFilesToPrefetch(project, projectViewSet, importRoots, blazeProjectData, externalFiles);
}
}
ListenableFuture<?> externalFilesFuture = prefetchFiles(project, externalFiles, false, false);
return Futures.allAsList(sourceFilesFuture, externalFilesFuture);
}
use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.
the class ProjectViewManagerImpl method getProjectViewSet.
@Nullable
@Override
public ProjectViewSet getProjectViewSet() {
if (projectViewSet == null && !projectViewSetLoaded) {
ProjectViewSet loadedProjectViewSet = null;
try {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
if (importSettings == null) {
return null;
}
File file = getCacheFile(project, importSettings);
List<ClassLoader> classLoaders = Lists.newArrayList();
classLoaders.add(getClass().getClassLoader());
classLoaders.add(Thread.currentThread().getContextClassLoader());
loadedProjectViewSet = (ProjectViewSet) SerializationUtil.loadFromDisk(file, classLoaders);
} catch (IOException e) {
logger.info(e);
}
this.projectViewSet = loadedProjectViewSet;
this.projectViewSetLoaded = true;
}
return projectViewSet;
}
use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method initTest.
@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
super.initTest(applicationServices, projectServices);
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", BuildSystem.Blaze));
projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
applicationServices.register(PrefetchService.class, new MockPrefetchService());
applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
// 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;
}
});
ExtensionPoint<JavaLikeLanguage> javaLikeLanguages = registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class);
javaLikeLanguages.registerExtension(new JavaLikeLanguage.Java());
javaLikeLanguages.registerExtension(new ScalaJavaLikeLanguage());
}
Aggregations