Search in sources :

Example 11 with BlazeImportSettings

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) PsiDirectory(com.intellij.psi.PsiDirectory) PsiManager(com.intellij.psi.PsiManager) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 12 with BlazeImportSettings

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
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings)

Example 13 with BlazeImportSettings

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) File(java.io.File) HashSet(java.util.HashSet)

Example 14 with BlazeImportSettings

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;
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) IOException(java.io.IOException) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 15 with BlazeImportSettings

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());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.sync.source.ScalaJavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.sync.source.ScalaJavaLikeLanguage) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) Nullable(javax.annotation.Nullable)

Aggregations

BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)16 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)8 File (java.io.File)6 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 Nullable (javax.annotation.Nullable)4 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)3 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)3 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)2 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)2 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 MockModule (com.intellij.mock.MockModule)2 MockPsiManager (com.intellij.mock.MockPsiManager)2 MockFileTypeManager (com.intellij.openapi.fileTypes.MockFileTypeManager)2 ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ProjectScopeBuilderImpl (com.intellij.psi.search.ProjectScopeBuilderImpl)2 IOException (java.io.IOException)2